Are you using the 'with' key in the model relationship? Are you doing
it in both directions? I don't know if it will help but I vaguely
remember something along these lines.

On Apr 3, 11:41 am, "Krissy Masters" <naked.cake.ba...@gmail.com>
wrote:
> Nothing. I simply want to first make sure no more than 5 are selected so I
> select 6 and submit.
>
> Debug data see 6
> Category Category array(
>         0 => 3
>         1 => 5
>         ....so on.)
>
> But no validation errors for Category. Just the Post...missing title,
> missing comment what not
>
> $this->Post->set($this->data);
>
> //Debug($this->Post->saveAll( $this->data, array('validate' => 'only')));
> $this->Post->saveAll( $this->data, array('validate' => 'only') )
>
> If I manually set data to the Category I get the messages saying too many
> selected so the validation in Category is set correct.
>
> I was just hoping saveAll would take care of this for me.
>
> I can wite validation anywhere set it to any model but figured why should I
> have to since all should be all :) Not some.
>
> K
>
>
>
>
>
>
>
> -----Original Message-----
> From: cake-php@googlegroups.com [mailto:cake-php@googlegroups.com] On Behalf
> Of euromark
> Sent: Sunday, April 03, 2011 9:07 AM
> To: CakePHP
> Subject: Re: Validate HABTM Multiple
>
> "but I never get any validation errors for the HABTM model "
>
> what does $this->Post->saveAll() return?
> boolean or array?
>
> pr() it pretty quick - I had similar issues I think
>
> On 1 Apr., 05:37, "Krissy Masters" <naked.cake.ba...@gmail.com> wrote:
> > I can, but why should I have to validate the Category in the Post model?
>
> > I was just under the assumption cake would handle that with saveAll since
> > there is nothing mentioning that it can't validate HABTM models. The "ALL"
> > in saveAll makes it sounds like it would save all related data.
>
> > $this->Post->saveAll( $this->data, array('validate' => 'only') ) to me
> > sounds like " if all of this data were to validate it could all be saved".
> > Post is related to Category HABTM relation and the book says save related
> > data in 1 call (db supports that is) if it validates.
>
> > Not being an ass but that sounds like saveSome() if your validating it
> > first.....no?
>
> > -----Original Message-----
> > From: cake-php@googlegroups.com [mailto:cake-php@googlegroups.com] On
> Behalf
>
> > Of Jeremy Burns | Class Outfit
> > Sent: Friday, April 01, 2011 12:53 AM
> > To: cake-php@googlegroups.com
> > Subject: Re: Validate HABTM Multiple
>
> > Couldn't you write a custom validation rule in the Post model that
> examines
> > the count of the Category key of the data array passed in?
>
> > Jeremy Burns
> > Class Outfit
>
> > jeremybu...@classoutfit.comhttp://www.classoutfit.com
>
> > On 1 Apr 2011, at 01:18, Krissy Masters wrote:
>
> > > How can you validate the number of "multiple" selected?
>
> > > I have a Post which hasMany, and HABTM relations so saving with :
>
> > > if ( $this->Post->saveAll( $this->data, array('validate' => 'only') ) )
> > > {//only testing to get errors
>
> > > but I never get any validation errors for the HABTM model
>
> > > Category:
> > > public $validate = array(
>
> > >            'Category' => array(
> > >                    'multiple' => array(
> > >                            'required' => false,
> > >                            'allowEmpty' => true,
> > >                            'rule' => array(
> > >                                    'multiple', array('max' => 3),
> > >                            'message' => 'Please select one, two or
> > > three options'))));
>
> > > Post HABTM Category
>
> > > Ideas?
>
> > > Thanks
>
> > > K
>
> > > --
> > > Our newest site for the community: CakePHP Video
> Tutorialshttp://tv.cakephp.org
> > > Check out the new CakePHP Questions sitehttp://ask.cakephp.organdhelp
> > others with their CakePHP related questions.
>
> > > To unsubscribe from this group, send email to
> > > cake-php+unsubscr...@googlegroups.com For more options, visit this group
> > athttp://groups.google.com/group/cake-php
>
> > --
> > Our newest site for the community: CakePHP Video
> Tutorialshttp://tv.cakephp.org
> > Check out the new CakePHP Questions sitehttp://ask.cakephp.organdhelp
> > others with their CakePHP related questions.
>
> > To unsubscribe from this group, send email to
> > cake-php+unsubscr...@googlegroups.com For more options, visit this group
> athttp://groups.google.com/group/cake-php
>
> --
> Our newest site for the community: CakePHP Video 
> Tutorialshttp://tv.cakephp.org
> Check out the new CakePHP Questions sitehttp://ask.cakephp.organd help
> others with their CakePHP related questions.
>
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group 
> athttp://groups.google.com/group/cake-php

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to