Quantcast
Channel: Yii Framework Forum
Viewing all articles
Browse latest Browse all 18717

Expression To Perform A Model Rule

$
0
0
Hi,

is there a way to apply a rule on Model by condition?
I mean something like that


public function rules() {
    array('specialattribute', 'numerical', 'integerOnly' => true, 
'when'=>'Yii::app()->user->checkAccess("superadmin") or a method'),
}


instead of

public function rules() {
    array('specialattribute', 'numerical', 'integerOnly' => true, 
'on'=>'superadmin'),
}


to avoid the repeateding set of scenario in Controllers/action

if there is no way yet, may be included in yii 2 :)

Viewing all articles
Browse latest Browse all 18717

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>