Home >Backend Development >PHP Tutorial >YII Validator DefaultValidator - Default value validator

YII Validator DefaultValidator - Default value validator

WBOY
WBOYOriginal
2016-07-29 09:06:051267browse

Function description:

1. Background verification: If the value is empty during verification, the default value will be assigned.

2. Foreground verification: Verify when the mouse loses focus; if there is a non-null (required) verification, non-null verification will be performed first. If there is no non-null verification, the default value will be automatically filled in after the mouse loses focus.

Usage:

// 在rules()函数中调用
$rules[] = Model::addRule('cat_sort', 'default', ['value' => '255']);

Parameter description:

1. Validator name: default

2. Parameter value specifies the default value for the attribute.

As shown in the picture:

When the mouse gains focus and clears the text box:
YII验证器 DefaultValidator - 默认值验证器

Automatically completes according to the default value after the mouse loses focus:

YII验证器 DefaultValidator - 默认值验证器

The above introduces the YII validator DefaultValidator - the default value validator, including the content. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn