Re: i18n in 1.2 model validation message
The correct way to show error message is like, in view, ?php echo $form-input('username', array('error' = array('alphanumeric' = __('Username must contain alpha-numeric characters', true), 'between' = __('Username must be between 8 to 20 characters', true; ? On Jan 5, 2008 5:12 AM, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: I have setup some 1.2 beta validation rules with the message key, but this throws and error. Any idea? Here is the piece from my model... public $validate = array( 'username' = array( 'alphanumeric' = array( 'rule' = 'alphaNumeric', 'message' = __('error_username', true) ), 'between' = array( 'rule' = array('between', 8, 20), 'message' = __('error_username_between', true) ), ), And here is the error... Parse error: syntax error, unexpected '(', expecting ')' in /home/ username/public_html/cake12/app/models/users.php on line 12 -- Regards, Amit http://amitrb.wordpress.com/ http://coppermine-gallery.net/ http://cheesecake-photoblog.org/ http://www.sanisoft.com/blog/author/amitbadkas --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: i18n in 1.2 model validation message
Yes, indeed it's the correct MVC way ..However, in case of multiple views it's convenient to be able to set the messages in model (I know, it breaks a bit the MVC rules)... On Jan 7, 1:20 pm, Amit Badkas [EMAIL PROTECTED] wrote: The correct way to show error message is like, in view, ?php echo $form-input('username', array('error' = array('alphanumeric' = __('Username must contain alpha-numeric characters', true), 'between' = __('Username must be between 8 to 20 characters', true; ? On Jan 5, 2008 5:12 AM, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: I have setup some 1.2 beta validation rules with the message key, but this throws and error. Any idea? Here is the piece from my model... public $validate = array( 'username' = array( 'alphanumeric' = array( 'rule' = 'alphaNumeric', 'message' = __('error_username', true) ), 'between' = array( 'rule' = array('between', 8, 20), 'message' = __('error_username_between', true) ), ), And here is the error... Parse error: syntax error, unexpected '(', expecting ')' in /home/ username/public_html/cake12/app/models/users.php on line 12 -- Regards, Amit http://amitrb.wordpress.com/http://coppermine-gallery.net/http://cheesecake-photoblog.org/http://www.sanisoft.com/blog/author/amitbadkas --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: i18n in 1.2 model validation message
I might not understand fully, but couldn't you do both? Set the message key for each validation in the model, then wrap the message key in the __() function in the view. Best of both worlds. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: i18n in 1.2 model validation message
I have a very similar problem. I think it might have to to with the fact that you are using a function in the declaration of the variable. I also want to use i18n to create the message. Please let me know if you solve the problem. Regards, Jonas On Jan 5, 12:42 am, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: I have setup some 1.2 beta validation rules with the message key, but this throws and error. Any idea? Here is the piece from my model... public $validate = array( 'username' = array( 'alphanumeric' = array( 'rule' = 'alphaNumeric', 'message' = __('error_username', true) ), 'between' = array( 'rule' = array('between', 8, 20), 'message' = __('error_username_between', true) ), ), And here is the error... Parse error: syntax error, unexpected '(', expecting ')' in /home/ username/public_html/cake12/app/models/users.php on line 12 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: i18n in 1.2 model validation message
This is the way I handled it : http://groups.google.com/group/cake-php/browse_thread/thread/fa32c81acc043eef/6a49c6d9fdc6f158?lnk=stq=#6a49c6d9fdc6f158 On Jan 6, 3:57 pm, Jonas Roslund [EMAIL PROTECTED] wrote: I have a very similar problem. I think it might have to to with the fact that you are using a function in the declaration of the variable. I also want to use i18n to create the message. Please let me know if you solve the problem. Regards, Jonas On Jan 5, 12:42 am, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: I have setup some 1.2 beta validation rules with the message key, but this throws and error. Any idea? Here is the piece from my model... public $validate = array( 'username' = array( 'alphanumeric' = array( 'rule' = 'alphaNumeric', 'message' = __('error_username', true) ), 'between' = array( 'rule' = array('between', 8, 20), 'message' = __('error_username_between', true) ), ), And here is the error... Parse error: syntax error, unexpected '(', expecting ')' in /home/ username/public_html/cake12/app/models/users.php on line 12 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: i18n in 1.2 model validation message
If you want localization of your validation error messages then it is best to define them in the views rather than the model - model just gives the type of error to the view and view sorts out what it needs to show for that error - that is the proposed 'CakePHP' way to do it. HTH Tarique On Jan 5, 2008 5:12 AM, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: I have setup some 1.2 beta validation rules with the message key, but this throws and error. Any idea? Here is the piece from my model... public $validate = array( 'username' = array( 'alphanumeric' = array( 'rule' = 'alphaNumeric', 'message' = __('error_username', true) ), 'between' = array( 'rule' = array('between', 8, 20), 'message' = __('error_username_between', true) ), ), And here is the error... Parse error: syntax error, unexpected '(', expecting ')' in /home/ username/public_html/cake12/app/models/users.php on line 12 -- = Cheesecake-Photoblog: http://cheesecake-photoblog.org PHP for E-Biz: http://sanisoft.com = --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---