Bonfreud
(Heavyfredmetal)
April 14, 2011, 1:40pm
1
how could I dynamically customize an error message (CActiveForm) ?
like in this code :
$form->error($model, $attribute, $htmlOptions)
I didn’t find a solution to indicate the error message…
Maybe there is a way to override dynamically the rules of the model (CActiveRecord) ?
thanks,
Freud
zaccaria
(Matteo Falsitta)
April 14, 2011, 1:45pm
2
The error message can be customized in the MODEL, in the function rules.
For example:
return array(
array('field1', 'required', 'message'=>'Please fill the field')
)
Bonfreud
(Heavyfredmetal)
April 14, 2011, 1:59pm
3
zaccaria:
The error message can be customized in the MODEL, in the function rules.
For example:
return array(
array('field1', 'required', 'message'=>'Please fill the field')
)
thank you for you answer but I would like to modify this rule dynamically…
I’m working on something to generate forms and I would like to specify this error message at the moment of the creation of the form, independently from the creation of the model…
Is it possible ?
mentel
(Yii)
April 14, 2011, 9:58pm
4
You may be able to achieve this by using the afterValidate event, see http://www.yiiframework.com/doc/api/1.1/CModel#afterValidate-detail