Пример #1
0
 /**
  * @inheritdoc
  */
 public function rules()
 {
     $rules = parent::rules();
     /* new country */
     $rules[] = ['country_id', 'string', 'max' => 255, 'when' => function ($model, $attribute) {
         return is_numeric($model->{$attribute}) == FALSE;
     }];
     /* new province */
     $rules[] = ['province_id', 'string', 'max' => 255, 'when' => function ($model, $attribute) {
         return is_numeric($model->{$attribute}) == FALSE;
     }];
     /* new city */
     $rules[] = ['city_id', 'string', 'max' => 255, 'when' => function ($model, $attribute) {
         return is_numeric($model->{$attribute}) == FALSE;
     }];
     /* new district */
     $rules[] = ['district_id', 'string', 'max' => 255, 'when' => function ($model, $attribute) {
         return is_numeric($model->{$attribute}) == FALSE;
     }];
     /* new subdistrict */
     $rules[] = ['subdistrict_id', 'string', 'max' => 255, 'when' => function ($model, $attribute) {
         return is_numeric($model->{$attribute}) == FALSE;
     }];
     return $rules;
 }