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
a 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.[...]