Commit 8b077e02 by Qiang Xue

minor doc edit [skip ci]

parent 7098ce45
...@@ -342,11 +342,11 @@ by calling `validateValue()`. ...@@ -342,11 +342,11 @@ by calling `validateValue()`.
### Handling Empty Inputs <a name="handling-empty-inputs"></a> ### 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. 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 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 ```php
[ [
...@@ -356,6 +356,16 @@ the [[yii\validators\Validator::isEmpty]] property. For example, ...@@ -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> ## Client-Side Validation <a name="client-side-validation"></a>
......
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