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 the
validation of the Tag model was ok.
With the other model associations I got the validation of both models
working by calling saveAll().
Isn't that possible with HABTM?
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 <theilen@eqi.de> 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: Foo HABTM Bar.
>>
>> 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 other validation rules 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 cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---
No comments:
Post a Comment