nette / forms

📝 Generating, validating and processing secure forms in PHP. Handy API, fully customizable, server & client side validation and mature design.

Home Page:https://doc.nette.org/forms

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Checkbox toggle issue

aleswita opened this issue · comments

commented

Version: 3.0.1

Bug Description

When checkbox marked as required, condition with toggle evaluated always to true and JS hide HTML attribute with ID data every time, if checkbox checked or not.
If commented setRequired, behaviour is OK.

Steps To Reproduce

protected function createComponentForm(): Nette\Application\UI\Form
{
	$form = new Nette\Application\UI\Form();

	$form->addCheckbox('checkbox', 'checkbox')
		->setOmitted()
		->setRequired()
		->addCondition(Nette\Forms\Form::EQUAL, false)
			->toggle('data')
		->endCondition();

	return $form;
}
{form form}
	<div id="data">
		...
	</div>

	{input checkbox}
{/form}

It is fixed but you should use ->addCondition($form::BLANK).