mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-16 06:17:56 +08:00
Merge https://github.com/yiisoft/yii2 into ru-docs-aliases
This commit is contained in:
@@ -342,11 +342,11 @@ by calling `validateValue()`.
|
||||
|
||||
### Handling Empty Inputs <a name="handling-empty-inputs"></a>
|
||||
|
||||
Validators often need to check if an input is empty or not. You may call [[yii\validators\Validator::isEmpty()]]
|
||||
Validators often need to check if an input is empty or not. In your validator, you may call [[yii\validators\Validator::isEmpty()]]
|
||||
to perform this check. By default, this method will return true if a value is an empty string, an empty array or null.
|
||||
|
||||
Users of validators can customize the default empty detection logic by configuring
|
||||
the [[yii\validators\Validator::isEmpty]] property. For example,
|
||||
the [[yii\validators\Validator::isEmpty]] property with a PHP callable. For example,
|
||||
|
||||
```php
|
||||
[
|
||||
@@ -356,6 +356,16 @@ the [[yii\validators\Validator::isEmpty]] property. For example,
|
||||
]
|
||||
```
|
||||
|
||||
When input data are submitted from HTML forms, you often need to assign some default values to the inputs
|
||||
if they are empty. You can do so by using the [default](tutorial-core-validators.md#default) validator. For example,
|
||||
|
||||
```php
|
||||
[
|
||||
// set "level" to be 1 if it is empty
|
||||
['level', 'default', 'value' => 1],
|
||||
]
|
||||
```
|
||||
|
||||
|
||||
## Client-Side Validation <a name="client-side-validation"></a>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user