Re: Validate rule: multiple (CookBook -> 4.1.4.17 Multiple)

2009-03-11 Thread WebbedIT
You will need to apply the validation rules in the Category and Scene models or in the beforeFilter of the model in which you are running the add/edit actions you can add $this->ModelName->Category->validate = array( 'Category' => array( 'rule' => array('multiple', array('min'=>

Re: Validate rule: multiple (CookBook -> 4.1.4.17 Multiple)

2009-03-10 Thread visskiss
Hey Paul, I'm trying this >     var $validate = array( >       'Role' => array( >         'rule' => array('multiple', array('min'=>1)), >         'message' => 'Select one or more roles' >       ) >     ); And it's not checking to see that at least one box is checked. Any ideas? In my case it's

Re: Validate rule: multiple (CookBook -> 4.1.4.17 Multiple)

2009-03-07 Thread WebbedIT
Sorry for the delayed response, the working validation role that I used was var $validate = array( 'Role' => array( 'rule' => array('multiple', array('min'=>1)), 'message' => 'Select one or more roles' ) ); This works with my RolesStaff model with form fields

Re: Validate rule: multiple (CookBook -> 4.1.4.17 Multiple)

2009-03-05 Thread YBin
Hello, I am looking for a way to do it in model page too. Any luck so far? Using HABTM classname for the fieldname doesn't work at all. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to thi

Re: Validate rule: multiple (CookBook -> 4.1.4.17 Multiple)

2009-03-02 Thread WebbedIT
petteyg, > If you read the book pages ... I did read the book (hence the subject of the thread) and my syntax copied that perfectly. 1. var $validate = array( 2.'multiple' => array( 3. 'rule' => array('multiple', array('in' => array('foo', 'bar'), 'min' => 1, 'max' => 3)), 4

Re: Validate rule: multiple (CookBook -> 4.1.4.17 Multiple)

2009-03-01 Thread petteyg
Well, first of all, your syntax is wrong. If you had read Abrar's example... Your code: var $validate = array( 'Role' => array( 'rule' => array('multiple', array('min' => 1)), 'message' => 'Please select at least one role' ) ); If you read the book pages (or Abrar's exam

Re: Validate rule: multiple (CookBook -> 4.1.4.17 Multiple)

2009-02-19 Thread WebbedIT
I have considered this and to be honest I will have to go down this route for this particular validation rule as it also has a dependency, but I was trying to get to the bottom of two things for future use: 1. How do I apply the built-in 'multiple' validation rule? 2. If Model::saveAll() saves H

Re: Validate rule: multiple (CookBook -> 4.1.4.17 Multiple)

2009-02-19 Thread Smelly_Eddie
WebbedIT I not sure if you have considered using your own validation method for all checkbox fields. You can use some simple logic to assess if one of the boxes is check, and return errors accordingly. Validation multiple fields with the OR conditon http://edwardawebb.com/programming/php-progra

Re: Validate rule: multiple (CookBook -> 4.1.4.17 Multiple)

2009-02-18 Thread WebbedIT
The question I guess I now need answered is why doesn't Modell::saveAll validate HABTM data before saving it? By digging into the core I found that Model::saveAll does not have a switch case for hasAndBelongsToMany, but by my limited logical reasoning that would mean the data would not get saved

Re: Validate rule: multiple (CookBook -> 4.1.4.17 Multiple)

2009-02-18 Thread WebbedIT
Thanks Abrar, Unfortunately you have not have read my post properly ... this is not multiple rules per field, it's the built-in cake 'multiple' rule clearly indicated by the subject of this thread. Paul. --~--~-~--~~~---~--~~ You received this message because you

Re: Validate rule: multiple (CookBook -> 4.1.4.17 Multiple)

2009-02-18 Thread Abrar Arshad
Hi, No need to force something in the controller to make working multiple rules on one field, you can do it this way. It means the value of rule key can have array of parameters with itself repeating in the array. var $validate = array( 'email'=> array(

Re: Validate rule: multiple (CookBook -> 4.1.4.17 Multiple)

2009-02-18 Thread WebbedIT
Update: I managed to get the 'multiple' rule working, but I am having to force it in my controller action as follows Role Model: validate = array( 'Role' => array( 'rule' => array('multiple', array('min'=>1)), 'message' => 'If approved, select one or more roles' ) ); Staff Controller

Validate rule: multiple (CookBook -> 4.1.4.17 Multiple)

2009-02-18 Thread WebbedIT
There doesn't seem to be much online about the use of this rule and I am having problems using it to make sure one checkbox is selected (searches for 'validate multiple' bring up loads about multiple rules per field). I first applied it as in the CookBook ... var $validate = array( 'multiple