How to customize error messages?

How to change  validator's built-in (default) messages on ContactForm from demo application generated by yiic tool?

For example:

Please fix the following input errors:

Name cannot be blank.

Email cannot be blank.

Subject cannot be blank.

Body cannot be blank.

The verification code is incorrect.

becomes:

Custom text:

Name custom text.

Email custom text.

Subject custom text.

Body custo text.

Custom text.

Specify a 'message' option in each rule.

Thank you very much.

I'm new to PHP.

Thanks, again.

No problem. As a generic guidance, configurations (like app config, rules) in Yii are all associated with objects and what you are configuring about are objects' properties. In the example of validation rules, you are configuring validator objects (base class is CValidator). So you can check the API of the corresponding validator classes to see what options are available.

any sample?

;D

http://www.yiiframew…doc/cookbook/1/

view



<?php echo CHtml::activeTextField($user,'username') ?>


<?php echo CHtml::error($user,'username'); ?>


controller

class ProfileController extends CController


{


	/**


	 * Declares class-based actions.


	 */


    public function rules()


    {


        return array(


            array('username','required','message'=>'ease enter a value for {attribute}.'),


        );


    }

error:






Login:





Usuario 


'Username cannot be blank.'





Quote

view


<?php echo CHtml::activeTextField($user,'username') ?>


<?php echo CHtml::error($user,'username'); ?>


controller

class ProfileController extends CController


{


	/**


	 * Declares class-based actions.


	 */


    public function rules()


    {


        return array(


            array('usuario','required','message'=>'ease enter a value for {attribute}.'),


        );


    }

error:






Login:





Usuario 


'Username cannot be blank.'





I think you should define the rule in AR Model class NOT in controller

ha ok, now under model usuario






	public function rules()


	{





		return array(


			array('usuario','length','max'=>255),


			array('senha','length','max'=>255),


			array('nome','length','max'=>255),


			array('email','length','max'=>255),


			array('cep','length','max'=>255),


			array('cidade','length','max'=>255),


			array('endereco','length','max'=>255),


			array('bairro','length','max'=>255),


			array('RG','length','max'=>255),


			array('CPF','length','max'=>255),


			array('fone','length','max'=>255),


			array('con','length','max'=>255),


			array('admin','length','max'=>255),


			array('sessionID','length','max'=>255),


			array('tema','length','max'=>255),


			array('usuario, senha, nome, email', 'required','message'=>'Campo nao pode ser vazio: {attribute}'),


			array('laboratorio_id, grupo_id', 'numerical', 'integerOnly'=>true),


		);


	}


same :

Please fix the following input errors:

Username cannot be blank.

Password cannot be blank.

fixed under model login form!

This is good. But, how can I change the main message ("Please fix the following input errors:")?

Check the API for CHtml::errorSummary().

Thanks.