kardais 0 Posted July 21, 2013 Report Share Posted July 21, 2013 Where does parameter "message" come from? I am going to change the default YII error message, but I didn't find the parameter in the models generated by YII. Thanks in advance, Kardais Quote Link to post Share on other sites
Jonathon 255 Posted July 22, 2013 Report Share Posted July 22, 2013 They are built into Yii's framework and meant to be over riden to customise your error messages. Quote Link to post Share on other sites
kardais 0 Posted July 22, 2013 Author Report Share Posted July 22, 2013 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 Quote Link to post Share on other sites
Edward 108 Posted July 22, 2013 Report Share Posted July 22, 2013 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? 1 Quote Link to post Share on other sites
kardais 0 Posted July 22, 2013 Author Report Share Posted July 22, 2013 Thank you very much, Edward. It is clear to me now. Regards, Kardais Quote Link to post Share on other sites
Larry 428 Posted July 22, 2013 Report Share Posted July 22, 2013 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. Quote Link to post Share on other sites
Edward 108 Posted July 22, 2013 Report Share Posted July 22, 2013 Okay, and what do you mean by Kardais? Oh sorry i apologize kardais the members name sorry. Quote Link to post Share on other sites
Larry 428 Posted July 22, 2013 Report Share Posted July 22, 2013 Sorry, Edward. Added spaces to make it more clear. Quote Link to post Share on other sites
Recommended Posts
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.