M
M
maximilianoarturo2016-02-09 20:54:52
Yii
maximilianoarturo, 2016-02-09 20:54:52

How to disable validation rule?

There is a field that is mandatory.
The task is to make it mandatory when adding a record and optional when editing (if left empty, just do not change)
That is, somehow disable the required rule from actionUpdate I
forgot to clarify that yii2

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
maximilianoarturo, 2016-02-09
@maximilianoarturo

Got it!
In rules() we replace
with
having previously added a constant
and in the actionCreate () method we write
$model->scenario = Administrator::SCENARIO_CREATE;

A
Andrey, 2016-02-09
@VladimirAndreev

['field', 'require', 'on'=>'insert'],
['fied', 'safe', 'on'=>'update']
if we are talking about the first yii

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question