Hi all!
I'm a cakephp developer, and i love all the great issues that cake
implements for you, like auth, acls, helpers in general and so on.
It's going close to ruby, this is a great effort that way!
congratulations!
As I'm having more and more experience, I find some things that could
be improved, like for example internationalization on the validation
of the models.
I have patched the cake code to make all the models to call a function
named "init", so i inserted a new line in the file "/cake/libs/
class_registry.php" next to the line 128 with this code:

${$class}->init();

Doing this, all the times that a model is instantiated, init() is
immediatetly called. Due to this, i had to put a function named
"init()" in the class "Model" of the file "/cake/libs/model/
model.php", because all the model classes inherit from "Model" class.
Doing this, if you want to override the init function in your model
to, for example, allow localization or method calling in the
validation of the model, you can do it!
The explanation is that, like many other languages like perl, c++, vb,
java, .... you cannot call any function during the declaration of a
variable of a class, but you can redefine that variable that you
declare inside the code!
So my model's code would be:

class User extends AppModel
{
    var $name           = 'User';
        var $validate   = NULL;

        function init()
        {
                $this->validate = array(
                                'nombre' => array(
                                                'regla1_nombre' =>
array(
                                                                        'rule'  
=> array('minLength','3'),
                                                                        
'message'       => __('Minimum length of 3 characters',true)
                                                                                
    ),
                                                'regla2_nombre' => array(
                                                                        'rule'  
=> array('maxLength','50'),
                                                                        
'message'       => __('Maximum length of 50 characters',true)
                                                                                
   )
                                                        )
                                                 );
        }

}

as you can see, i redefined validate array inside init() method.

So i think it would be great for all the cake comunity to have this
concept implementated on the next release of cake!
Hope this help any people!
regards

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to