I'm trying to set a custom id
for an input
field whilst using ActiveField in Yii2
.
I tried the below, but it instead set the id
of the field container instead of the input
field itself.
$form->field($model, 'some_id', ['options' => ['id' => 'some_id']])->hiddenInput(['value' => $some_id])->label(false);
Is there a way I can set the id
attribute of the input field itself?
I noticed the inputOptions option, but this seems to control the setting for all the fields, so unsure how it works exactly with the selectors etc.
Just add id
key to options array you've already passed in to hiddenInput
method
$form->field($model, 'some_id')->hiddenInput(['value' => $some_id, 'id' => 'some_id'])->label(false);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With