12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- <?php
- namespace yii\validators;
- class DefaultValueValidator extends Validator
- {
-
- public $value;
-
- public $skipOnEmpty = false;
-
- public function validateAttribute($model, $attribute)
- {
- if ($this->isEmpty($model->$attribute)) {
- if ($this->value instanceof \Closure) {
- $model->$attribute = call_user_func($this->value, $model, $attribute);
- } else {
- $model->$attribute = $this->value;
- }
- }
- }
- }
|