Skip to content

Instantly share code, notes, and snippets.

@Vp3n
Created January 22, 2012 21:53
Show Gist options
  • Save Vp3n/1659036 to your computer and use it in GitHub Desktop.
Save Vp3n/1659036 to your computer and use it in GitHub Desktop.
Validation conditionnelle
class A
{
public function configure()
{
$this->validatorSchema['A1']->setOption('required', false);
$this->validatorSchema['A2']->setOption('required', false);
}
public function doBind(array $values)
{
if(array_key_exists('A2', $values) && $values['A2'])
{
$this->validatorSchema['A1']->setOption('required', true);
}
parent::doBind($values);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment