Special Validation Rule - Fill out a Field or another group of Fields

Comparing #2 with #3

Revision #3 was created by Kabinenkoffer Kabinenkoffer on May 8, 2014, 3:28:17 PM.

editing

Content

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'), ... } ~~~```