Phptp verification form and auto-fill function code _ PHP Tutorial

Source: Internet
Author: User
Phptp verification form and auto-fill function code. Copy the code as follows :? PhpclassFormModelextendsModel {Automatic Verification settings ** 1: automatic verification is defined as follows: array (field, rule, message, condition The code is as follows:


Class FormModel extends Model {
// Automatic verification settings
/*
* 1. Automatic Verification
Automatic verification is defined as follows: array (field, rule, message, condition, type, when, params)
Field: indicates the field name of the database;
Rule: indicates a rule;
The value depends on the type;
If condition is function (callback), rule is a function name.
Condition is in, and rule is an array
Message: indicates a message prompt;
Condition: indicates a verification condition.
Its value:
Self: MUST_VALIDATE indicates that 1 must be verified.
Self: VALUE_VAILIDATE indicates verification 2 when not empty
Self: EXISTS_VAILIDATE indicates that fields in the form are verified (default). 0
Type: indicates the verification type.
Its value:
Function (callback) indicates that the function in a Model is called.
Confirm indicates verifying whether the two fields are the same
Whether in is within the range of an array
Equal verify whether it is equal to a value
Unique verifies that a value is unique
Regex uses regular expressions (default)
When: indicates whether verification is required.
Its value:
Self: INSERT_STATUS verification during the add operation
Self: verified during the UPDATE_STATUS update operation
Self: ALL_STATUS (needless to say)
Params: parameter (I am not sure about the specific information)
**/
Protected $ _ validate = array (
Array ('title', 'require ', 'The title is required! ', 1), // must be verified
Array ('email ', 'Email', 'mailbox format error! ', 2), // verification when not empty
Array ('content', 'require ', 'content required '),
Array ('title', '', 'title already exists ', 0, 'Unique', self: MODEL_INSERT ),
);
// Automatic filling settings
// Array (fill field, fill content, fill condition, additional rules)
/* Fill conditions include:
Processing when adding new data (default mode) self: filling when MODEL_INSERT ADD operation
When updating data, process the self: MODEL_UPDATE udate operation.
ALL is processed in ALL cases. self: MODEL_BOTH (needless to say)
Additional rules include:
Function usage function
Callback method
Fill field with other fields
String (default)
*/
Protected $ _ auto = array (
Array ('status', '1', self: MODEL_INSERT ),
Array ('create _ time', 'time', self: MODEL_INSERT, 'Function '),
);
}
?>

The http://www.bkjia.com/PHPjc/325132.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/325132.htmlTechArticle code is as follows :? Php class FormModel extends Model {// automatic verification settings/** 1: The definition of automatic verification is as follows: array (field, rule, message, condition...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.