Answer the question
In order to leave comments, you need to log in
Disappears class in ActiveForm?
Good afternoon. There is a form and there is a field
<?= $form->field($model->main, 'alias')->textInput(['maxlength' => true]) ?>
<div class="form-group field-navigations-alias required">
<label class="control-label col-md-3" for="navigations-alias">Псевдоним</label><div class="col-md-9"><input type="text" id="navigations-alias" name="Navigations[alias]">
<span class="help-block"></span></div>
</div>
<?= $form->field($model->main, 'alias', ['options' => ['style' => 'display:none']])->textInput(['maxlength' => true]) ?>
<div class="field-navigations-alias required" style="display:none">
<label class="control-label" for="navigations-alias">Псевдоним</label>
<input type="text" id="navigations-alias" class="form-control" name="Navigations[alias]" maxlength="255" aria-required="true">
<div class="help-block"></div>
</div>
Answer the question
In order to leave comments, you need to log in
If you look at the sources of the ActiveField class (which is actually used when calling the $form->field() method), you will see that the default html options property is written
accordingly when you make a call to the field() method in the style
html-options written by default are replaced by the values you passed.
There are two ways to solve this problem:
1. Forcibly set the css class in the required fields, for example
2. Force css-class for all form fields, for example:
$form = ActiveForm::begin([
'fieldConfig' => [
'options'=>[
'class' => 'form-group'
]
]
]);
<?= $form->field($model->main, 'alias'])->textInput(['maxlength' => true, 'style' => 'display:none']) ?>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question