Multiple Validation

Hi,

i need little help.

I have a few fields and all of them are required.

I wrote validator:

array('field1, field2, field3,…, ‘required’, ‘message’=>‘this field is required’).

but In summary error Ive got:

This field is required

This field is required

This field is required

This field is required…

is there any trick that i will have:

The field1 is required

The field2 is required

The field3 is required

The field4 is required…

without creating 4 or more arrays(validators)??

I want to keep my code as simple as possible :)

I think you can use placeholder {attribute} in your message property

read this =>

http://www.yiiframework.com/doc/api/1.1/CValidator#message-detail

and this =>

http://www.yiiframework.com/wiki/1/how-to-customize-the-error-message-of-a-validation-rule/

PS: I didn’t test it

Thanks, it works:)


array('username,password', 'required', 'message'=>'Please fill {attribute}'),