Fix #18175: Add upgrade note for 2.0.36 about inline validator defined as closure

This commit is contained in:
Alexander Makarov
2020-08-07 11:38:10 +03:00
parent 7e2601fa1c
commit 523e4b324b

View File

@ -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).