Ahmad Samilo
Ahmad Samilo

Reputation: 271

use conditional statements in model

Is it possible to add conditional statements in Yii model

for eaxmple :

in users model I need to check if user is admin then in update information Controller mobile number field will display as required filed , but if user is normal user change field properties to empty or not required

array('mobile','length', 'max'=>14 ,'min'=>3),

Thanks in advance

Upvotes: 0

Views: 69

Answers (1)

vaibhav
vaibhav

Reputation: 133

echo (if(isset(admin_session))) ? 'write the update code for admin' : 'write the normal user update code';

Upvotes: 1

Related Questions