mirror of
https://github.com/yiisoft/yii2.git
synced 2025-08-14 06:11:35 +08:00

The `DefaultValueValidator` works only with closures not with any callable as suggested.
See f8337a15c2/framework/validators/DefaultValueValidator.php (L47)
```
/**
* {@inheritdoc}
*/
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;
}
}
}
```