My symfony 1.* memory is very hazy at this point but I think what you need to do here is add a rule to the validatorSchema
to handle validation of this widget.
According to the Validation Appendix the validator you need is sfValidatorChoice
.
This widget has a number of options, including:
- multiple
- min
- max
Assuming that you have two options as above, and you want to enforce selecting both, I'm guessing that you might need to add the following to your form's configure()
method:
public function configure()
{
$this->widgetSchema['consent_confirmation'] = new sfWidgetFormSelectCheckbox(array(
'choices' => array(
'1' => 'Yes I agree to #1',
'2' => 'Yes I agree to #2',
)),
);
$this->validatorSchema['consent_confirmation'] = new sfValidatorChoice(array(
'multiple' => true,
'min' => 2,
'max' => 2,
));
}
Something like that - I'm not sure about the assignment to the validatorSchema to be honest, there might be something like addValidator()
or setValidator()
methods instead. EDIT: I think there were some helper methods added, but some of these might be 1.4 specific. The above assignment should work either way...
Hope this helps :)