Jump to content
Larry Ullman's Book Forums

Parameter "Message" On Chapter 5


kardais
 Share

Recommended Posts

Page 86 says:

 

 

As with almost everything in Yii, if you don’t like the default response, you can
easily change it. To change the default error message for an attribute, assign a new
value to the message property:
array('email', 'email',
'message'=>'You must provide an email address
to which you have access.'),
array('pass', 'match', 'pattern'=>'/^[a-z0-9_-]{6,20}$/',
'message'=>'The password must be between 6 and 20 characters
long and can only contain letters, numbers, the underscore,
and the hyphen.'),
 
I am still unclear with this passage, where must I put that statement?
 
Best Regards,
Kardais
Link to comment
Share on other sites

You have to add to the rules() array in the model where you have the attribute that you need to change the default error message

 

array('title','required', 'message'=>'Enter a title for your item!'),

 

in the array message is they key and the value attribute is 'Enter a title for your item!';

 

So if you have a title attribute as in the above, you have to add message in as another parameter in the array. Its as simple as that or am i missing something?

  • Upvote 1
Link to comment
Share on other sites

Thanks, Edward!

 

Kardais, if you would do me a favor and just reply to messages using the reply box, not hitting "Quote", that'd be great. There's really no need to duplicate the previous person's content if that's what you're replying to.

Link to comment
Share on other sites

 Share

×
×
  • Create New...