mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-01 11:39:41 +08:00
Fix #18175: Add upgrade note for 2.0.36 about inline validator defined as closure
This commit is contained in:
@ -96,6 +96,16 @@ Upgrade from Yii 2.0.35
|
||||
// $current === 'second' (on second iteration)
|
||||
}
|
||||
```
|
||||
|
||||
* `$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
|
||||
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