Form->addRule : Constants not working: What is my mistake? OR Docs not up-to-date?
- Nicolas_K
- Member | 25
1. This is my form in my HomepagePresenter:
According to https://doc.nette.org/…in-presenter#…
:
(copied from the doc)
2. This is the result – given by Tracy:
“Undefined constant Nette\Application\UI\Form::Range”
The same with other constants like MinLength, MaxLength, Pattern.
According to https://doc.nette.org/…s/validation#…
and https://api.nette.org/…ms/Form.html
these constants should work (?)
3. When I do it this way, it works!
4. This my actual composer.json
- Rick Strafy
- Nette Blogger | 81
Hi, you need to select correct version in the docs, for some reason 4.0 is default, 3.x is here https://doc.nette.org/…lidation/3.x.
- Lumeriol
- Generous Backer | 64
Nicolas_K wrote:
1. This is my form in my HomepagePresenter:
You must use constants with uppercases, like $form::RANGE, $form::PATTERN etc.
Constants as PascalCase are defined in Nette\Forms 4.0, that is not fully released, but documentation is ready for that. It is reason, why 3rd point is fully works.