WebbedIT I not sure if you have considered using your own validation method for all checkbox fields.
You can use some simple logic to assess if one of the boxes is check, and return errors accordingly. Validation multiple fields with the OR conditon http://edwardawebb.com/programming/php-programming/cakephp/validating-optional-fields-cakephp-dreaded-scenario On Feb 18, 9:17 am, WebbedIT <[email protected]> wrote: > The question I guess I now need answered is why doesn't > Modell::saveAll validate HABTM data before saving it? > > By digging into the core I found that Model::saveAll does not have a > switch case for hasAndBelongsToMany, but by my limited logical > reasoning that would mean the data would not get saved either, yet it > does. > > I amended lines #1511 to #1525 to the following which results in my > HABTM model getting validated as required and my data is being saved > as expected, but I don't fully follow the code so there's a high > chance this is not a sensible solution: > > if (isset($associations[$association])) { > switch ($associations[$association]) { > case 'belongsTo': > case 'hasAndBelongsToMany': // added > if ($this->__save($this->{$association}, $values, $options)) { > $data[$this->alias][$this->{$associations[$association]} > [$association]['foreignKey']] = $this->{$association}->id; // edited > } else { > $validationErrors[$association] = > $this->{$association}->validationErrors; > > $validates = false; > } > if (!$options['atomic']) { > $return[$association][] = $validates; > } > break; > } > } --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" 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/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---
