Page 1 of 4
1 · 2 · 3 · 4

Abba Bryant :: 09.02.2009 17:33:45
Mind if I ask why you don't use the more recognized ( less php5ish ) method of simply assigning the public $validate = array( ... ); method of assigning your validation array?
lecterror :: 09.02.2009 17:37:54

I'm forced to do it this way because of the gettext calls e.g.:

__('Passwords do not match', true)

Which cannot be used in a variable declaration. Hope that clears it up ;-)
amit :: 22.02.2009 15:20:37
Faced the same problem and your article helped a lot, thanks
Antonio Kobashikawa Carrasco :: 08.03.2009 13:42:37
Hi, thank you for your post, I use this aprox.
However, about use __construct() to declare validation rules because you can't use __() when define $validate, I use $validate in usually way, and __() not in model else in the controller, as in:

var $validate = array(
'rule'=>array('custom', '/^[0-9A-Za-z\_\-]{5,255}$/'),
'message'=>'Only alphanumeric characters please'

<?php __($form->error(''))?>
lecterror :: 08.03.2009 14:51:36

I understand why you want to it like that (much cleaner and backwards compatible), but I don't believe that your strings will be extracted by cake i18n shell when used that way.

I believe that makes it a bit more complicated to maintain.