You should check this: http://bakery.cakephp.org/articles/nachopitt/2010/07/01/habtm-validatable-behavior
On 15 jun, 08:24, Shaz <shazam...@gmail.com> wrote: > I haven't actually made models for the Join table - I don't think you > need to for a HABTM relationship > > On Jun 15, 1:41 pm, Rob Maurer <robmau...@gmail.com> wrote: > > > > > > > > > Interesting. What would happen if you put the validation in the model > > for the join table? > > > On Jun 14, 3:17 pm, Shaz <shazam...@gmail.com> wrote: > > > > I can - but in that arises another situation: > > > > I also have Location HABT Language - and I don't want any restrictions > > > there. So a location can have more than 3 or no languages associated > > > with it. > > > > So if place the above $validate in language model, both users and > > > locations will need to pass that validation; where I only want the > > > users to... > > > > Thanks! > > > > On Jun 14, 8:14 pm, hunny <saurabh85maha...@gmail.com> wrote: > > > > > Write the Validation Rule in Language Model instead of User Model > > > > > On Jun 14, 9:56 pm, Shaz <shazam...@gmail.com> wrote: > > > > > > I have User HABTM Language, and i want to ensure during a User add / > > > > > edit they choose a minimum of one language, upto a maximum of 3. In > > > > > the user model, for $validate I've tried: > > > > > > 'Language' => array( > > > > > 'multiple' => array( > > > > > 'rule' => array('multiple', > > > > > array('min' => 1, 'max' => 3)), > > > > > 'message' => 'Please select a tleast > > > > > 1 langiage upto a maximum of > > > > > 3' > > > > > ), > > > > > ), > > > > > > And in the add/edit form i have $this->Form->input('Language'); which > > > > > doesn't actually validate. > > > > > > It does work if I use language_id instead of Language (both in the > > > > > form on the add/edit pages and in the model $validate) - but then it > > > > > doesn't save any data in the join table. > > > > > > Any advice on getting the above to validate, or save habtm when using > > > > > "_id". -- 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