Revision #3 has been created by Kabinenkoffer on May 8, 2014, 3:28:17 PM with the memo:
editing
« previous (#2)
Changes
Title
unchanged
Special Validation Rule - Fill out a Field or another group of Fields
Category
unchanged
How-tos
Yii version
unchanged
Tags
unchanged
validation rules
Content
changed
RequirementHow-To use a special validation rule
-----------
If you have a form, you sometimes need special validation Rules not included in Yii. Here i share a special rule with you, i just wrote. Maybe you have the case, when a user needs to Fill ou Field A oder the Fields B, C and D.
~~~
```php
public function thisOrThatRequired($attribute, $params) {
if ($params['check']) {[...]
}
}
~~~```
~~~
```php
public function rules() {
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
....
array('firma', 'thisOrThatRequired', 'check' => 'vorname,nachname,anrede','on'=>'insert,rework'),
...
}
~~~```