Difference between #26 and #27 of
Reference: Model rules validation

Revision #27 has been created by François Gannaz on Feb 19, 2013, 8:19:26 AM with the memo:

fix bad code example (a method with no side effect should be static)
« previous (#26) next (#28) »

Changes

Title unchanged

Reference: Model rules validation

Category unchanged

How-tos

Yii version unchanged

Tags unchanged

Form validation, model, validation, reference, validation rules, validator

Content changed

[...]
1. **filter**, the filter method.

*Examples:*

- With
standarda custom function ```php array('mycode','filter','filter'=>'strtoupper'), ``` - With custom functionmethod ```php array('eanupc','filter','filter'=>array($this,'keepProductCode')), array('eanupc','filter','filter'=>array(self,'formatProductCode')),
 
... public function keepProductCode($eanupccode){ // return ltrim(substr($eanupc,6,6),'0');s a new value (uses $this) ...
 
}
 
static public function formatProductCode($code){
 
// returns a new value (cannot use $this) ...

}
```
*NOTE:* The filter validator maybe use with other validators for the same attribute. In this case one must pay attention to the order of the validators list as the filter validator will change the attribute value.
[...]
99 0
114 followers
Viewed: 891 789 times
Version: 1.1
Category: How-tos
Written by: krillzip
Last updated by: Rodrigo
Created on: Nov 29, 2009
Last updated: 11 years ago
Update Article

Revisions

View all history