PHP TP Validation form and automatic fill function code _php tips

Source: Internet
Author: User
Copy Code code as follows:

<?php
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 name of a database;
Rule: The representative is the rules;
Its value depends on the type;
If the condition is a function (callback), rule is a function name
Condition is In,rule is an array
Message: The representative is a news hint;
Condition: Represents a validation condition
Its value:
Self::must_validate says you must verify 1
Self::value_vailidate 2 When the expression is not empty
Self::exists_vailidate indicates that the form exists with field validation (default) 0
Type: Represents the validation type
Its value:
The function (callback) indicates that the validation is a call to the functions in model
Confirm to verify that two fields are the same
In whether or not within an array range
Equal verification is equal to a value
Unique verifies that a value is unique
Regex uses regular expressions (default)
When: represents whether validation is required
Its value:
Self::insert_status add operation when validation
Validation when Self::update_status UPDATE operation
Self::all_status (needless to say)
Params: parameters (Specific What I'm not sure yet)
* */
Protected $_validate = Array (
Array (' title ', ' Require ', ' title must be! ', 1,//must verify
Array (' email ', ' email ', ' mailbox format error!) ', 2,//NOT NULL-time validation
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
When update data is processed, the Self::model_update udate operation is populated
All cases are processed self::model_both (needless to say)
Additional rules include:
function using Functions
Callback callback method
Field fills with other fields
String string (default method)
*/
Protected $_auto = Array (
Array (' status ', ' 1 ', Self::model_insert),
Array (' Create_time ', ' time ', Self::model_insert, ' function '),
);
}
?>

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.