Codxplore.com

Latest news: New android application Islamic Video has been released. its a free islamic video application for android smartphone. Download now!


 

Its called 'scenarios': http://www.yiiframework.com/doc-2.0/guide-structure-models.html#scenarios

in model:

public function rules()
{
    return [
        ['title', 'required', 'on' => 'create']
    ];
}

in controller:

public function actionCreate()
{
     $model = new Item();
     $model->scenario = 'create';
     ...
}

You'd better define scenario as a constant though.

 

source : http://stackoverflow.com/questions/29449019/yii2-validate-only-create-action

Tags : Yii, Yii2,

Views : 3300

Subscribe Us


Follow Us