Hi,
You can create a custom post validator, something like this:
class AllOrNoneValidator extends sfValidatorBase
{
public function configure($options = array(), $messages = array())
{
$this->addRequiredOption('field1');
$this->addRequiredOption('field2');
$this->addRequiredOption('field3'); // these are the field names
from your PersonInviteForm.
$this->addMessage('error', 'Fill in all fields, or none.');
}
public function doClean($values)
{
if ($values['field1'] == '' && $values['field2'] == '' &&
$values['field3'] == '') // all fields are empty (of course you can
use more sophisticated checks here)
{
return $values; // let it pass
}
if ($values['field1'] != '' && $values['field2'] != '' &&
$values['field3'] != '') // all fields are filled in
{
return $values; // let it pass
}
throw new sfValidatorError($this, 'error'); // do not let it pass
(something must be wrong)
}
}
Then you attach this as post validator to your form as (this code
might not be 100% correct) :
$personForm->getValidatorSchema()->setPostValidator(new
AllOrNoneValidator(array('field1' => 'field1', 'field2' => 'field2',
'field3' => 'field3')));
Regards,
Zoltan.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"symfony users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---