PHP TP Validation form with AutoFill function code _php Tutorial

Source: Internet
Author: User
Copy CodeThe code is as follows:
Class Formmodel extends Model {
Automatic Validation settings
/*
* One: Automatic verification
The definition of automatic validation is this: Array (field,rule,message,condition,type,when,params)
Field: Represents the domain name of the database;
Rule: The representative is the rules;
Its value depends on the type;
If condition is function (callback), rule is a function name
Condition is In,rule is an array
Message: The delegate is a news prompt;
Condition: Represents a validation condition
The value of it:
Self::must_validate indicates that 1 must be verified
Self::value_vailidate indicates that it is not empty when validating 2
self::exists_vailidate field validation for form presence (default) 0
Type: Represents the validation type
The value of it:
function (callback) means that the functions in the call to a model are validated
Confirm to verify that two fields are the same
In is within an array range
Equal verify that a value is equal to
Unique verifies that a value is unique
Regex uses regular expressions (default)
When: represents whether validation is required
The value of it:
Self::insert_status when the add operation is validated
Self::update_status when the UPDATE operation is verified
Self::all_status (needless to say)
Params: parameters (Specific What I'm not sure yet)
* */
Protected $_validate = Array (
Array (' title ', ' Require ', ' title must! ', 1),//Must be verified
Array (' email ', ' email ', ' email ' format Error! ', 2),//Not for null-time verification
Array (' content ', ' require ', ' contents must '),
Array (' title ', ' ', ' title already exists ', 0, ' unique ', Self::model_insert),
);
Auto-fill settings
Array (fill field, fill content, fill condition, attach rule)
/* Fill conditions include:
Add new data when processing (default) self::model_insert add operation when filling
Update data is processed when the Self::model_update udate operation is filled
All cases are handled self::model_both (needless to say)
Additional rules include:
function usage Functions
Callback callback method
Field fills with other fields
String strings (default mode)
*/
Protected $_auto = Array (
Array (' status ', ' 1 ', Self::model_insert),
Array (' Create_time ', ' time ', Self::model_insert, ' function '),
);
}
?>

http://www.bkjia.com/PHPjc/325132.html www.bkjia.com true http://www.bkjia.com/PHPjc/325132.html techarticle Copy the code as follows:? PHP class Formmodel extends Model {//Auto-Verify Settings/*: auto-validation is defined as the definition of automatic validation: array (field,rule,message,condition. .

  • Related Article

    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.