Form shows error “This field is required.” but everything is fine
- silviustan
- Member | 22
Hi,
Anybody had this issue before?
I have a form with multiple fields, doesn't matter, because in the end I commented everything except the submit button and addProtection method. When I submit it, the form has one error “This field is required.” and the error's key is 0, so is not field specific.
Weird is that this kind of code works fine for other forms…and I don't
understand where this error is coming.
Highly appreciated may be also a method to debug forms deeper…
Can you help me?
Nette version 2.4
Code looks extremely simple after commenting all fields for debugging:
<?php
protected function createComponentFieldForm()
{
$form = new Form;
/* fields are here but commmented to avoid any extra validation */
$form->addSubmit('save', 'Save changes');
$form->onSuccess[] = [$this, 'FieldFormSubmitted'];
$form->addProtection();
return $form;
}
?>
- Marek Bartoš
- Nette Blogger | 1261
addProtection()
also adds a field (visually hidden). Is form
connected to presenter's component tree and is session working? It depends on
these two.
- silviustan
- Member | 22
@Mabar , thank you for your answer, but I found the mistake.
It was a html tag which wasn't closed…but I couldn't imagine that it will cause that. The error was confusing, like something wasn't validated.