I noticed that when I don't add PresenceOf validator to the element, during validation the form - validators will still run for this item.
$element = new Text('test');
$element->setFilters(array('striptags', 'int'));
$element->addValidators(array(
/* new PresenceOf(array(
'message' => 'please fill in'
)), */
new Between(array(
'minimum' => 0,
'maximum' => 100,
'message' => 'The value must be between 0 and 100'
)),
));
$this->add($element);
Show error "The value must be between 0 and 100"
I guess it's a bug beacause this validator should run only if it's not empty.
I guess also
@Jurigag can you look? https://github.com/phalcon/cphalcon/issues/11584
@sergeyklay can you look? I guess it's a bug
Which version of Phalcon did you use
I use Phalcon 2.1.0.RC1
@googlle What about this feature https://github.com/phalcon/cphalcon/blob/2.1.x/phalcon/validation.zep#L475
You could add ''allowEmpty' => true' to the validator, allowing empty submition.
$element = new Text('test');
$element->setFilters(array('striptags', 'int'));
$element->addValidators(array(
new Between(array(
'minimum' => 0,
'maximum' => 100,
'message' => 'The value must be between 0 and 100',
'allowEmpty' => true
)),
));
$this->add($element)
https://docs.phalconphp.com/en/latest/reference/validation.html#avoid-validate-empty-values
Thanks to everybody