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'=>
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
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
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
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
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
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
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
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
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
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(
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
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
13 matches
Mail list logo