Reputation: 2848
I have written this code in the 'BaseUserForm' class located in {app}/lib/form/doctrine/base
am trying to add two validators to the EMAIL field.
$this->setValidators(array(
'id' => new sfValidatorChoice(array(
'choices' => array(
$this->getObject()->get('id')
),
'empty_value' => $this->getObject()->get('id'),
'required' => false
)),
'name' => new sfValidatorString(array('max_length' => 50)),
'email' => array(
new sfValidatorString(array('max_length' => 100)),
new sfValidatorEmail(array('trim' => true))
),
'password' => new sfValidatorString(array('max_length' => 100)),
'retyepassword' => new sfValidatorString(array('max_length' => 100)),
'city_id' => new sfValidatorDoctrineChoice(array(
'model' => $this->getRelatedModelName('Cities')
)),
'phone' => new sfValidatorNumber(),
'created' => new sfValidatorDateTime(),
'updated' => new sfValidatorDateTime(),
));
The code above gives error on the defining of two validators for email field.
Also I am finding it difficult to find out the code related (example showing the usage) of these validators. The jobeet tutorial is not of much help.
Please share some good blogs/articles/forums wherein i can find help related to the issues discussed above.
Thanks
Upvotes: 1
Views: 860
Reputation: 460
'email' => new sfValidatorEmail(array('max_length' => 25, 'required' => TRUE),
array('invalid' => 'The email address is invalid.', 'required' => 'Email Id is required.', 'max_length'=> 'Maximum 25 characters allowed.')),
Upvotes: 1