Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Rotua Panjaitan
yii2
Commits
e1edb190
Commit
e1edb190
authored
Jun 12, 2014
by
zxcq544
Browse files
Options
Browse Files
Download
Plain Diff
Merge
https://github.com/yiisoft/yii2
into ru-docs-aliases
parents
45169ee1
8b077e02
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
2 deletions
+12
-2
input-validation.md
docs/guide/input-validation.md
+12
-2
No files found.
docs/guide/input-validation.md
View file @
e1edb190
...
...
@@ -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.
Y
ou may call
[
[yii\validators\Validator::isEmpty()
]
]
Validators often need to check if an input is empty or not.
In your validator, y
ou 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>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment