i have two forms holds the same model attributes, since Yii2 generate the field id to be ModelName-fieldName so the field generated will be as follow:
<select name="Channel[channel]" class="form-control" id="channel-description">
i have tried to use fieldConfig in Activeform but it doesn't add the id to the field itself.
You should simply use the third parameter of ActiveForm::field()
:
$options
: The additional configurations for the field object.
e.g. :
$form->field($model, 'channel', ['inputOptions' => ['id' => 'channel-description']])
Read more about ActiveForm::field().
But if you really want to add a prefix to all your fields ids, you should override ActiveForm
.