mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-03 05:48:11 +08:00
Fix #18175: Add upgrade note for 2.0.36 about inline validator defined as closure
This commit is contained in:
@ -97,6 +97,16 @@ Upgrade from Yii 2.0.35
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
* `$this` in an inline validator defined as closure now refers to model instance. If you need to access the object registering
|
||||||
|
the validator, pass its instance through use statement:
|
||||||
|
|
||||||
|
```php
|
||||||
|
$registrar = $this;
|
||||||
|
$validator = function($attribute, $params, $validator, $current) use ($registrar) {
|
||||||
|
// ...
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
* If you have any controllers that override the `init()` method, make sure they are calling `parent::init()` at
|
* If you have any controllers that override the `init()` method, make sure they are calling `parent::init()` at
|
||||||
the beginning, as demonstrated in the [component guide](https://www.yiiframework.com/doc/guide/2.0/en/concept-components).
|
the beginning, as demonstrated in the [component guide](https://www.yiiframework.com/doc/guide/2.0/en/concept-components).
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user