A
A
Adel1ne2019-04-02 17:35:07
Yii
Adel1ne, 2019-04-02 17:35:07

Yii2 How to set different validation rules for multiple input of one attribute?

Let's say there are two inputs for one model attribute:
$form->field($model, 'price[]')->textInput(['id'=>'price1'])
$form->field($model, 'price []')->textInput(['id'=>'price2'])
I need to configure the validation so that the first input is required for input, and the second is not.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2019-04-02
@dimoff66

What type of attribute do you have? From the code, you can see that the model will receive an array. Array and validate with a function on the server, or validate on the client.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question