Hi!
Can someone explain to me why there is even such a flag as allowEmpty
in Zend_Form_Element?
This to me seems like a job for a validator, and there is no reason
that I can see why empty values should be treated differently
(skipping validators, auto-adding of validators(NonEmpty), etc.) than
any other values.
I've created custom Date, Time and DateTime elements, and used
something like this in them:
public function init()
{
$this->addValidator('Date', false, array('yyyy-MM-dd
HH:mm:ss'));
}
Naturally, I would expect that I would either:
a) get a valid date OR
b) get NULL (if the element wasn't required).
But no. "" also sneaks through, even though it clearly wouldn't pass
the validators, if they ran (but they don't).
So perhaps I should also check if there are any other special values,
like "Hello!", that would entirely bypass the validation, and call
setAllowHello(false) and setAllowILoveZendFramework(false) (just
making my point :P)
Is it legacy problem, or am I missing something?
Best regards,
Jaka Jancar