diff --git a/framework/UPGRADE.md b/framework/UPGRADE.md index 5d9e903e4d..ec571a5077 100644 --- a/framework/UPGRADE.md +++ b/framework/UPGRADE.md @@ -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).