How to add a for attribute to a label? I try it, it does not work

$form->field($user, 'approve')->checkbox( ['id'=>'user-approve','labelOptions'=>['for'=>'user-approve']] ) 

And for example, it works

 $form->field($user, 'approve')->checkbox( ['id'=>'user-approve','labelOptions'=>['for111'=>'user-approve']] ) 
  • But doesn’t the label automatically put an attribute when adding an id main element? - Alexey Shimansky
  • No, in any case I do not. - Just a guest
  • Generally, to be honest, working with forms in Yii begins to annoy me a little: ( - Just a guest

1 answer 1

Why don't you want to use something like that?

 $form->field($user, 'approve')->checkbox( ['id'=>'user-approve']-label('sometext', ['for'=> ''user-approve''])