Commit ca07eae0 by Alexander Makarov

Merge pull request #3105 from githubjeka/patch-4

Update model.md
parents a4809bca 846433bc
......@@ -287,6 +287,23 @@ public function rules()
}
```
When you need conditional validation logic on client-side (`enableClientValidation` is true), don't forget
to add `whenClient`:
```php
public function rules()
{
$usa = [
'server-side' => function($model) { return $model->country == Country::USA; },
'client-side' => "function (attribute, value) {return $('#country').value == 'USA';}"
];
return [
['state', 'required', 'when' => $usa['server-side'], 'whenClient' => $usa['client-side']],
];
}
```
Massive Attribute Retrieval and Assignment
------------------------------------------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment