I have the same problem. It saves automatically but validation won't run. To me it seems like the logical place to put these validation rules is on the join table in the HABTM relationship. Ie PostsTag model, but unfortunately it doesn't run.
It's weird that it will happily save the data, but it won't validate by default. On Mar 2, 6:01 pm, Günther Theilen <[email protected]> wrote: > Hi, > > thank for the answer. > > I read the blog entry before but it didn't seem to be the most elegant > way because in teknoid's example the Post model is only validated if > thevalidationof the Tag model was ok. > > With the other model associations I got thevalidationof both models > working by calling saveAll(). > Isn't that possible withHABTM? > > Regards > Guenther > > brian schrieb: > > > Have a look here > > >http://teknoid.wordpress.com/?s=validate+habtm > > > On Fri, Feb 27, 2009 at 9:30 AM, Günther Theilen <[email protected]> wrote: > >> Hi, > > >> maybe I'm a bit dull but I can't figure out what I'm doing wrong here. > >> Maybe someone can help: > > >> I've got two models: FooHABTMBar. > > >> In foo_controller, add method I do this: > > >> $bar = $this->Foo->Bar->find('list'); > >> $this->set(compact('bar)); > > >> In the foo/add view I have: > >> $form->input('Bar', array('multiple' => 'checkbox')) > > >> Which works as I expected. > > >> Now I want to validate the checkboxes. > > >> In models/bar.php I added > >> var $validate = array('Bar' => array('rule' => 'testRule')); > > >> function testRule() { > >> debug ("test"); > >> die(); > >> } > > >> In foo_controller, add method I tried this: > >> $this->Foo->save($this->data) > >> and this: > >> $this->Foo->saveAll($this->data) > >> and this: > >> $this->Foo->saveAll($this->data, array('validate' => 'first')) > > >> All my othervalidationrules in the Foo-model work perfectly but the > >> rule in Bar doesn't seem to be triggered. > > >> Where is my mistake? > >> Any hints? > > >> Regards > >> Guenther --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
