Replace input field prefix

Hi,

I have noticed that each input fields in a form is prefixed by the model type.

ex:




<input id="myform-firstname" />

<input id="myform-lastname" />



Is there a way to change the prefix “myform” so that it’s not based on the model type MyForm? In the ActiveForm class there is a property named autoIdPrefix, maybe this is the one to set. I’ve tried but probably I did it incorrectly.

Thanks,

Alex

You could possible use the "options" array config for the field and set the ID to what you want.




<?php echo $form->field($model, "myField")->textarea(["id" => "myNewID"]); ?>



James.

I already knew that it’s possible to do that. In order for the validation to work, I think the selectors property must be modified also.

Plusm my form has like 15 fields so I’d prefer if it’s possible to do the change in batch.

Thanks for your input though.