Hi everyone, I am very much new to Yii framework.
In the definitive guide on Yii, I have question on the design on Form Builder. How come the design didn’t use the rules() defined in the Model? Instead, we now have to create an additional config. In the following example, you would be left with a inconsistent case where config has maxlength = 32, but Model has max = 12
From Form Builder guide, you have the following statement
$form = new CForm('application.views.site.loginForm', $model);
And the LoginForm is basically the config
return array(
'title'=>'Please provide your login credential',
'elements'=>array(
'username'=>array(
'type'=>'text',
'maxlength'=>32,
)
}
Now, notice that it actually has some logic that seems to belong to the Model domain (i.e. length).
The reason being, if you look back at earlier tutorial on form model, we have rules() function that has something like
array('username', 'length', 'min'=>3, 'max'=>12)
Thank you for reading