See the paragraph "Global validators" in http://www.symfony-project.org/book/forms/1_2/en/02-Form-Validation.
I think your problem will be better handled by a global validator as it regards more than one input field. Martino On Wed, Feb 18, 2009 at 1:16 PM, Mark Smith <marksmith5...@jungle-monkey.com> wrote: > > I have a dynamic 2d array of checkboxes, and I want to require that at > least one is selected. Trying to write validation rules for this is > proving to be excruciatingly difficult. > > The only way I could accomplish this is to override the isValid > function and put in some logic to manually check each box. > > It causes the form not to validate, but obviously does nothing to the > error schema: > > public function isValid() > { > $result=false; > > foreach($this['requiredServices'] as $service) > { > foreach($service as $region) > { > if($region->getValue()) > { > $result=true; > break; > } > } > } > > > return $result && parent::isValid(); > } > > > > Is there a better way than this? > > Thanks > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "symfony users" group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en -~----------~----~----~----~------~----~------~--~---