[userinput] definition: required vs. optional
Hi,
Just looking at the UserInput component for the first time, I completed
the tutorial sample code, seems to run fine, but I seem to have found
some inconsistencies:
With definition:
$definition = array(
'firstName' => new ezcInputFormDefinitionElement(
ezcInputFormDefinitionElement::REQUIRED, 'string' ),
'lastName' => new ezcInputFormDefinitionElement(
ezcInputFormDefinitionElement::REQUIRED, 'string' ),
'age' => new ezcInputFormDefinitionElement(
ezcInputFormDefinitionElement::REQUIRED, 'int', array( 'min_range' => 1,
'max_range' => 99 ), FILTER_FLAG_ALLOW_HEX ),
'email' => new ezcInputFormDefinitionElement(
ezcInputFormDefinitionElement::REQUIRED, 'validate_email' ),
);
If I submit an empty form, "age" and "email" get [invalid] warning, and
"first name" and "last name" don't.
1) Since first and last name are REQUIRED, why is an empty string
interpreted as valid?
2) When I change REQUIRED to ezcInputFormDefinitionElement::OPTIONAL,
nothing seems to change. So how do I make an e-mail field optional, as
in "validate the field if some value provided"? It doesn't seem to have
any extra options to control that...
Thanks,
Piotrek