Monday, March 2, 2009

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

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. 'message' => 'Please select one, two or three options'
5. )
6. );

> If you had read Abrar's ...
I also read Abrar's example and it was unrelated. As I explained in
my reply to his post, I know how to apply multiple rules to one field,
but I was applying *one* built-in rule which happens to be called
*multiple*.

> you'd see that [the validation rule]
> should be the following:
Your posted example is an overview of how to apply multiple rules per
field using an array which, as with Abrar's reply, is not what I
originally posted about. You do not need to use that method if only
applying one rule no matter how many options that one rule may have as
per the book

1. var $validate = array(
2. 'fieldName1' => array(
3. 'rule' => 'ruleName', // or: array('ruleName', 'param1',
'param2' ...)
4. 'required' => true,
5. 'allowEmpty' => false,
6. 'on' => 'create', // or: 'update'
7. 'message' => 'Your Error Message'
8. )
9. );

I am happily and properly using validation across 20+ models applying
single and multiple built-in and custom validation rules. My query
was very specific to using the built-in multiple rule and, to use your
unnecessary tone back at you, if you had read my 2nd and last posts
properly you will see that I managed to answer my own question about
applying the multiple rule and I was only left with the question why
doesn't saveAll validate HABTM data before saving it?

So the only thing left to address was why saveAll did not apply my
HABTM validation rules before saving .. I posted a dirty hack to make
saveAll read my HABTM rule but then asked the question should saveAll
do this by default?

Sorry if the tone of my reply is a little harsh, as I truly welcome
anyone's attempts to resolve the issues that I post to the group and
hope that you contribute to future posts of mine, but if you are going
to accuse people of not reading things please take the time to make
sure you have read all the related information yourself.

Thanks,

Paul (Webbed IT)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
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?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: