Wednesday 18 April 2012

 How To Chang a Error Message For Yii?
 ===================================================

Open your model file then find below function and changes it

 public function rules() {
        $message ="<span class='ui-icon ui-icon-alert'></span><span class='app'>". Yii::t('app','{attribute} cannot be blank.')."</span>";
        return array(

        array('firstname, lastname, email, username, password, restaurant_name, created_at, is_active', 'required','message'=>$message),
        array('wizard_step, send_email_updates, agree_terms, is_disabled, parent_id', 'numerical', 'integerOnly'=>true),
        array('user_type', 'length', 'max'=>7),
        array('firstname, lastname', 'length', 'max'=>50),
        array('email', 'length', 'max'=>128),
        array('username, password', 'length', 'max'=>40),
        array('restaurant_name, user_roles', 'length', 'max'=>255),
        array('id_register_hear_aboutus, id_register_identify_question', 'length', 'max'=>11),
        array('lognum', 'length', 'max'=>5),
        array('is_active', 'length', 'max'=>8),
        array('restaurant_desc, updated_at, logdate, extra', 'safe'),
        array('user_type, wizard_step, restaurant_desc, send_email_updates, agree_terms, id_register_hear_aboutus, id_register_identify_question, updated_at, logdate, lognum, user_roles, extra, is_disabled, parent_id', 'default', 'setOnEmpty' => true, 'value' => null),
        array('id, user_type, firstname, lastname, email, username, password, wizard_step, restaurant_name, restaurant_desc, send_email_updates, agree_terms, id_register_hear_aboutus, id_register_identify_question, created_at, updated_at, logdate, lognum, is_active, user_roles, extra, is_disabled, parent_id', 'safe', 'on'=>'search'),
        );
    }

2 comments: