Jump to content
Larry Ullman's Book Forums

Parameter "Message" On Chapter 5


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 post
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 post
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 post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...