contributte / forms-multiplier

:repeat: Form multiplier & replicator for Nette Framework

Home Page:https://contributte.org/packages/contributte/forms-multiplier.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Wrong adding order when 2 multipliers in form group

llsm opened this issue · comments

Hi,
i have two multipliers in one form group and when i try to add field in first one, field is after second multiplier as shown on image:

multiplier

Can you send me code of form, please?

	$form = new \Nette\Application\UI\Form;

	$form->addText('name', 'jméno')
			->addRule($form::FILLED, 'Vyplňte jméno');
	$form->addText('surname', 'příjmení')
			->addRule($form::FILLED, 'Vyplňte příjmení');

	$copies = 1;
	$maxCopies = 3;
	$mailMultiplier = $form->addMultiplier('mailMultiplier', function (\Nette\Forms\Container $container, \Nette\Application\UI\Form $form) {
		$container->addText('mail', 'kontaktní e-mail')
				->setType('email')
				->setRequired('Zadejte prosím e-mail.')
				->addRule($form::EMAIL, 'Zkontrolujte překlepy v e-mailu, zadaná adresa není platná');
	}, $copies, $maxCopies);
	$mailMultiplier->addCreateButton('Zadat další e-mail');
	$mailMultiplier->addRemoveButton('Odstranit e-mail');


	$telMultiplier = $form->addMultiplier('telMultiplier', function (\Nette\Forms\Container $container) {
		$container->addText('tel', 'kontaktní telefon')
				->setRequired('Vyplňte telefonní číslo');
	}, $copies, $maxCopies);
	$telMultiplier->addCreateButton('Zadat další telefon');
	$telMultiplier->addRemoveButton('Odstranit telefon');


	$form->addSubmit('save', 'Odeslat');
	$form->onSuccess[] = [$this, 'processForm'];

	return $form;

Can you try dev?

Same issue + messes up add/delete buttons labels on second element of multiplier, which works fine in 2.0.4

How do you render form?

Standard latte {control form} macro

Sorry for delay, I had to overwrite the algorithm.