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
Hi,

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:

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

add.ctp
<?php __($form->error('User.name'))?>
lecterror :: 08.03.2009 14:51:36
Hi!

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.