Answer the question
In order to leave comments, you need to log in
What is the great point of adding hidden fields to ActiveForm?
I have not been familiar with Yii2 for a long time. Gradually I try to master ActiveForm. Now I came across an interesting thing, in the code I write:
<?= $form->field($model, 'price')->radio(['value' => 'common', 'id' => 'price-common', 'label' => 'Обычная цена']); ?>
<div class="form-group field-orderform-price required">
<input type="hidden" name="OrderForm[price]" value="0"> <!--Вот эта строка непонятна-->
<label><input type="radio" id="price-common" name="OrderForm[price]" value="common"> Обычная цена</label>
<div class="help-block"></div>
</div>
Answer the question
In order to leave comments, you need to log in
I don’t fully understand what the cymes is, but the dock says this:
uncheck: string, the value associated with the uncheck state of the radio button. If not set, it will take the default value '0'. This method will render a hidden input so that if the radio button is not checked and is submitted, the value of this attribute will still be submitted to the server via the hidden input. If you do not want any hidden input, you should explicitly set this option as null.
As I understand it, this allows you to override the values that come to the server if the checkbox is not checked and not affected in the process of filling out the form at all.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question