Trying to start using rules, but not sure how they're validated
- blackcat562
- Member | 10
I am using this snippet I found in the docs:
$form->addPassword('password', 'Password:')
// if password is not longer than 5 characters ...
->addCondition(Form::MAX_LENGTH, 5)
// ... then it must contain a number
->addRule(Form::PATTERN, 'Must contain number', '.*[0-9].*');
Also, I am using standalone forms, but I am not sure I understand when
these rules are checked?
when I click submit, the form goes thru even if the rules in the code above are
not met.
1* Is there an extra step I am missing to validate these rules?
Another thing I am noticing is when I create a field like this:
$form['section']->setRequired('Select a section!!!')->setPrompt('Select a seating section');
I never see the setRequired
message anywhere, even when
I enable nette.js
, this is the HTML and you can see the error is
in the data json, but the window only says “This field is required”, see
this image:
https://take.ms/Nuj24
2* Are these limitations when using standalone forms?
Last edited by blackcat562 (2019-04-15 08:18)