contributte/forms-multiplier

Wrong adding order when 2 multipliers in form group

llsm opened this issue · 7 comments

llsm commented

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?

llsm commented
	$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?

llsm commented

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?

llsm commented

Standard latte {control form} macro

Sorry for delay, I had to overwrite the algorithm.