kardais Posted July 21, 2013 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 Link to comment Share on other sites More sharing options...
Jonathon Posted July 22, 2013 Share Posted July 22, 2013 They are built into Yii's framework and meant to be over riden to customise your error messages. Link to comment Share on other sites More sharing options...
kardais Posted July 22, 2013 Author 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 Link to comment Share on other sites More sharing options...
Edward Posted July 22, 2013 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 Link to comment Share on other sites More sharing options...
kardais Posted July 22, 2013 Author Share Posted July 22, 2013 Thank you very much, Edward. It is clear to me now. Regards, Kardais Link to comment Share on other sites More sharing options...
Larry Posted July 22, 2013 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. Link to comment Share on other sites More sharing options...
Edward Posted July 22, 2013 Share Posted July 22, 2013 Okay, and what do you mean by Kardais? Oh sorry i apologize kardais the members name sorry. Link to comment Share on other sites More sharing options...
Larry Posted July 22, 2013 Share Posted July 22, 2013 Sorry, Edward. Added spaces to make it more clear. Link to comment Share on other sites More sharing options...
Recommended Posts