add error for sfValidatorOr in Symfony
I have:
$this-&开发者_JAVA技巧gt;validatorSchema->setPostValidator(new sfValidatorOr(
array(
new sfValidatorSchemaCompare('email', '!=', ''),
new sfValidatorSchemaCompare('phone', '!=', ''),
),
array(),
array('invalid' => 'Campo obligatorio')
));
Error is in $form->getGlobalErrors(). How can i add
array('throw_global_error' => true),
same as here:
$this->validatorSchema->setPostValidator(
new sfValidatorOr(
array(
new sfValidatorAnd(
array(
new sfValidatorSchemaCompare('date_from', sfValidatorSchemaCompare::EQUAL, 'date_to',
array('throw_global_error' => true),
array('invalid' => 'The start date ("%left_field%") must be equal the end date ("%right_field%")')),
new sfValidatorSchemaCompare('time_from', sfValidatorSchemaCompare::LESS_THAN, 'time_to',
array('throw_global_error' => true),
array('invalid' => 'The start time ("%left_field%") must be before the end time ("%right_field%")')),
)),
new sfValidatorSchemaCompare('date_from', sfValidatorSchemaCompare::LESS_THAN, 'date_to',
array('throw_global_error' => true),
array('invalid' => 'The start date ("%left_field%") must be before the end date ("%right_field%")')),
)
));
?
i will render this :
<?php $form['email']->renderLabel() ?>
**<?php echo $form['email']->getError() ?>**
but in sfValidatorOr this doesn't work
You can put the throw_global_error option directly on sfValidatorSchemaCompare().
There is no way to put it on the sfValidatorOr as it's not a sfValidatorSchema object.
精彩评论