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

Number type input validation problem if number type input depends on other input

forgie1 opened this issue · comments

Version: 3.3.0 and others

Bug Description

If input is of type number and depends on other input and number validation fails, than form is not valid but no error is added to Nette.formErrors. Even no further errors are added.

Steps To Reproduce

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

		$dep = $form->addCheckbox('dep', 'Num required');

		$num = $form->addText('num', 'Number');
		$num->setHtmlAttribute('type', 'number');
		$num->addConditionOn($dep, $form::EQUAL, true)->setRequired();

		$form->addText('required', 'Required')->setRequired();

		$form->addSubmit('submit', 'done');

		return $form;
	}

Check the checkbox.
Enter non numeric value, eg 5X to Number field.
Do not fill Required field.
And submit the form.

No error is displayed.

Expected Behavior

Two errors should be displayed:

  1. Please enter a valid value.
  2. This field is required.

Possible Solution

See related MR.