php tp validation forms with auto populate function code

  • 2020-05-12 02:24:20
  • OfStack

 
<?php 
class FormModel extends Model { 
//  Automatic verification Settings  
/* 
* 1 : automatic verification  
 The definition of automatic validation looks like this: array(field,rule,message,condition,type,when,params) 
field: Represents the field name of the database;  
rule: Representation is the rule;  
 It depends on its value type Depending on the type of;  
 If it is condition  is function ( callback ), rule is 1 A function name  
condition  is in . rule is 1 An array  
message: A delegate is a message prompt;  
condition : represents the validation condition  
 Its value:  
self::MUST_VALIDATE  Means must be verified 1 
self::VALUE_VAILIDATE  Verify when it is not empty 2 
self::EXISTS_VAILIDATE  Field validation for the existence of the form (default) 0 
type : represents the validation type  
 Its value:  
function(callback)  It is the call that represents validation 1 a Model The function in  
confirm  Means to verify that the two fields are the same  
in  Is it within the range of an array  
equal  Verify that it is equal to some value  
unique  Verify that a value is only 1 
regex  Using regular expressions (default)  
when: Represents whether validation is required  
 Its value:  
self::INSERT_STATUS add Verify at operation time  
self::UPDATE_STATUS update Verify at operation time  
self::ALL_STATUS  (needless to say)  
params : parameters (I don't know the details yet)  
* */ 
protected $_validate = array( 
array('title','require',' The title must! ',1),// Must be validated  
array('email','email',' Email format error! ',2),// Not null time validation  
array('content','require',' The content must be '), 
array('title','',' The title already exists ',0,'unique',self::MODEL_INSERT), 
); 
//  Automatic fill setting  
//array( Fill fields, fill content, fill conditions, attach rules ) 
/*  Filling conditions include:  
ADD  Processing when adding data (default)  self::MODEL_INSERT add Fill while operating  
Update  Process when updating data  self::MODEL_UPDATE udate Fill while operating  
ALL  In all cases  self::MODEL_BOTH  (needless to say)  
 Additional rules include:  
function  Using the function  
callback  The callback method  
field  Fill it with other fields  
string  String (default)  
*/ 
protected $_auto = array( 
array('status','1',self::MODEL_INSERT), 
array('create_time','time',self::MODEL_INSERT,'function'), 
); 
} 
?> 

Related articles: