Reputation: 12923
so I wrote a custom date validater called Date and when I try and use it, zend falls back to the zend_validate_date call:
$datePosted = new Zend_Form_Element_Text('datePosted');
$datePosted->setLabel('Date Job Was Posted?: ')
->setRequired(true)
->addFilter('stripTags')
->addFilter('stringTrim')
->addPrefixPath('Hg2_Validate_Date', 'Hg2/Validate/', 'validate')
->addValidators(array(
array(
'validator' => 'NotEmpty',
'breackChainOnFailure' => true
),
array(
'validator' => 'stringLength',
'options' => array(0, 10)
),
array(
'validator' => 'Date'
),
array(
'validator' => 'alnum',
'options' => array('allowWhiteSpaces' => true)
)
));
return $datePosted;
This is what I have and it should use my date and not zends date no?
the custom validation can be seen by the addPrefixPath() where I add my custom validator to this element. My understanding is that now if I call Date or date bellow in the 'validator' it will call my date and not zends?
Upvotes: 1
Views: 344
Reputation: 3128
As a prefix you don't have to add the _Date
to the path. If you look at the documentation
addPrefixPath($prefix, $path, $type = null)
adds a prefix/path association to the loader specified by $type.
With your current prefix argument this will probably extend to a class named Hg2_Validate_Date_Date
which it will not find.
So this should work for you
->addPrefixPath('Hg2_Validate', 'Hg2/Validate/', 'validate')
Upvotes: 3