Uniform using with panel tags

Hi together,

currently I’m going to build a form tag with the uniform plugin. Unfortunately this does not work to 100%. One form on the page works. With two forms on one side there are funny effects.

If the first form is sent, the error message will also appear in the second form.

When the second form is sent, the tag appears: (form: …)

Here is an example and the code as gist.

Example: https://test.kleiner-als.de

https://gist.github.com/schnti/b275c1eaea199b78b2e5d60affdd7476

Can anybody help me?

Multiple static forms on one page is one edge case that doesn’t work with Uniform v3 yet. It’s on the radar but as you can always use AJAX forms instead it’s not very high priority. So my advice is to use AJAX forms with different routes as endpoints.

I’m very interested in using your plugin with multiple static forms, how can I help you to implement this?
AJAX isn’t a real alternative.

I fount this method parameter in the kirby-flash-Plugin $session_key = '_flash', maybe this can be used for multiple static forms. I passed it through up to the Form($session_key, $rules = []) constructor. That did not help.

$form = new Form($formName, [
	'recipient' => [
		'rules' => ['required'],
		'message' => 'Please choose a recipient',
	],
	'name' => [
		'rules' => ['required'],
		'message' => 'Gebe bitte deinen Namen an',
	],
	'email' => [
		'rules' => ['required', 'email'],
		'message' => 'Email is required',
	],
	'message' => [
		'rules' => ['required'],
		'message' => 'Gebe bitte eine Nachricht an',
	],
]);
if (r::data($formId) != null) {

	$form->logAction([
		'file' => kirby()->roots()->site() . '/../log/' . $formName . '.log',
	]);
}

I think the problem is the singleton Flash instance,. Once inizialized, this value will no longer be overwritten.

Fork:
https://github.com/schnti/kirby-uniform

First you have to modify kirby-flash so a non-static/-singleton instance can be created. It should remain fully backwards compatible, though. Then you have to modify kirby-form to accept an optional session key. I’d set this as a second constructor parameter as it should be optional but the rules array is required. With the session key a non-singleton Flash instance is created which is unique for the form. Finally you can update Uniform to optionally accept that second parameter as well.

Feel free to create PRs to the repos. kirby-flash and kirby-form are forks of mine since jevets, the original author, currently has no time to maintain them. We can develop this further in the PRs.

You’re lucky. I’ve just implemented all that while I brought kirby-flash and kirby-form in better shape. Check out the current master of Uniform and see if it works for you. Set the form ID like this.