Example #1
0
 /**
  * Validator which checks the fieldtype
  *
  * Also ensures that field_type_class could not be changed on existing records.
  */
 public function checkType()
 {
     if (!$this->isNewRecord) {
         // Dont allow changes of internal_name - Maybe not the best way to check it.
         $currentProfileField = ProfileField::model()->findByPk($this->id);
         if ($this->field_type_class != $currentProfileField->field_type_class) {
             $this->addError('field_type_class', Yii::t('UserModule.models_ProfileField', 'Field Type could not be changed!'));
         }
     } else {
         if (!key_exists($this->field_type_class, ProfileFieldType::getFieldTypes())) {
             $this->addError('field_type_class', Yii::t('UserModule.models_ProfileField', 'Invalid field type!'));
         }
     }
 }