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:
Automatically completes according to the default value after the mouse loses focus:
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.