yii-user extension (Yii 1.1.x) - Error Message doesn't seem to work

Hello,

I’ve created a field using profile fields of yii-user extension (Yii 1.1.x). I have added value in error message field for custom error message. But it doesn’t seem to work. I have tried this with INTEGER and VARCHAR fields.

For a VARCHAR field I created, the rules is as follows:


array (size=5)

      0 => string 'error_msg_varchar_check' (length=23)

      1 => string 'length' (length=6)

      'max' => string '255' (length=3)

      'min' => string '5' (length=1)

      'message' => string 'This is an error message' (length=24)

But, the custom error message is not displaying even if I entered the value less than 5 or greater than 255. It just shows the default messages. Anybody knows why it shows like that?

This is how the rules section in the model looks like:




/**

	 * @return array validation rules for model attributes.

	 */

	public function rules()

	{

		if (!$this->_rules) {

			$required = array();

			$numerical = array();

			$float = array();		

			$decimal = array();

			$rules = array();

			

			$model=$this->getFields();

			

			foreach ($model as $field) {

				$field_rule = array();

				if ($field->required==StudentProfileField::REQUIRED_YES_NOT_SHOW_REG||$field->required==StudentProfileField::REQUIRED_YES_SHOW_REG)

					array_push($required,$field->varname);

				if ($field->field_type=='FLOAT')

					array_push($float,$field->varname);

				if ($field->field_type=='DECIMAL')

					array_push($decimal,$field->varname);

				if ($field->field_type=='INTEGER')

					array_push($numerical,$field->varname);

				if ($field->field_type=='VARCHAR'||$field->field_type=='TEXT') {

					//echo $field->error_message;exit;

					$field_rule = array($field->varname, 'length', 'max'=>$field->field_size, 'min' => $field->field_size_min);

					if ($field->error_message) $field_rule['message'] = UserModule::t($field->error_message);

					array_push($rules,$field_rule);

				}

				if ($field->other_validator) {

					if (strpos($field->other_validator,'{')===0) {

						$validator = (array)CJavaScript::jsonDecode($field->other_validator);

						foreach ($validator as $name=>$val) {

							$field_rule = array($field->varname, $name);

							$field_rule = array_merge($field_rule,(array)$validator[$name]);

							if ($field->error_message) $field_rule['message'] = UserModule::t($field->error_message);

							array_push($rules,$field_rule);

						}

					} else {

						$field_rule = array($field->varname, $field->other_validator);

						if ($field->error_message) $field_rule['message'] = UserModule::t($field->error_message);

						array_push($rules,$field_rule);

					}

				} elseif ($field->field_type=='DATE') {

					$field_rule = array($field->varname, 'type', 'type' => 'date', 'dateFormat' => 'yyyy-mm-dd', 'allowEmpty'=>true);

					if ($field->error_message) $field_rule['message'] = UserModule::t($field->error_message);

					array_push($rules,$field_rule);

				}

				if ($field->match) {

					$field_rule = array($field->varname, 'match', 'pattern' => $field->match);

					if ($field->error_message) $field_rule['message'] = UserModule::t($field->error_message);

					array_push($rules,$field_rule);

				}

				if ($field->range) {

					$field_rule = array($field->varname, 'in', 'range' => self::rangeRules($field->range));

					if ($field->error_message) $field_rule['message'] = UserModule::t($field->error_message);

					array_push($rules,$field_rule);

				}

			}

			

			array_push($rules,array(implode(',',$required), 'required'));

			array_push($rules,array(implode(',',$numerical), 'numerical', 'integerOnly'=>true));

			array_push($rules,array(implode(',',$float), 'type', 'type'=>'float'));

			array_push($rules,array(implode(',',$decimal), 'match', 'pattern' => '/^\s*[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?\s*$/'));

			$this->_rules = $rules;

		}

		return $this->_rules;

	}



I just noted that the rules function lacks one closing curly braces, making all other functions like relations and attributeLabels to be written inside the rules function. However, adding an extra closing curly braces generates a syntax error. Strange! :-o

Can anyone help me with a solution? :unsure: