A
A
assx642017-02-01 22:44:59
Yii
assx64, 2017-02-01 22:44:59

Yii2 Unable to fill in subsequent fields?

Such a question, there is CRUD. For example, _form.php has three fields:

<div class="row">
                <div class="col-md-4 vcenter">
                    <?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
                </div>
            </div>
            <div class="row">
                <div class="col-md-4 vcenter">
                    <?= $form->field($model, 'name_co')->textInput(['maxlength' => true]) ?>
                </div>
            </div>
            <div class="row">
                <div class="col-md-4 vcenter">
                    <?= $form->field($model, 'name_red')->textInput(['maxlength' => true]) ?>
                </div>
            </div>

How to make each subsequent field, after the first, be blocked for input until the previous one is filled?
I suppose you need to look in the direction of the validators, and tentatively write your own for each field, although it is repeated based on the previous one, but I can’t figure it out. I would be grateful for help in this matter.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim Timofeev, 2017-02-01
@webinar

It is necessary to look towards js.

M
Maxim Fedorov, 2017-02-02
@qonand

It is not worth implementing such functionality using validators. The task of validators is to check the data for compliance with the incoming data to certain rules, and blocking form fields is the task of the form itself. Therefore, as Maxim Timofeev said , implement the functionality using js, and attach it directly to the form. You should not sculpt functionality that logically does not apply to validators on them ...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question