Php tp verification form and auto-Fill function code

Source: Internet
Author: User

Copy codeThe Code is as follows:
<? Php
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 '),
);
}
?>

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.