Thursday, March 31, 2011

Validate HABTM Multiple

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 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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: