Yii2: ActiveField::checkbox() render duplicate labels

Created on 19 Sep 2014  路  4Comments  路  Source: yiisoft/yii2

When use code

<?=
  $form->field(
    $model,
    'is_registered',
    ['template' => '{input}{label}{error}']
  )->checkbox()->label()
 ?>

it render HTML like

<label>
  <input id="my-input" type="checkbox">
  My label
<label>
<label for="my-input">My Label</label>

instead

<input id="my-input" type="checkbox">
<label for="my-input">My Label</label>
bug

Most helpful comment

You should use ->checkbox([], false) or ->checkbox(['label' => null]).

All 4 comments

You should use ->checkbox([], false) or ->checkbox(['label' => null]).

I used

->checkbox([], false)

and it doesn't work, but

->checkbox(['label' => null])

works fine. I thank that $enclosedByLabel = false is disabling enclose by label

Just checked in a fix. Both should work fine now. Thanks.

Works perfect. Thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

AstRonin picture AstRonin  路  3Comments

Kolyunya picture Kolyunya  路  3Comments

chaintng picture chaintng  路  3Comments

Locustv2 picture Locustv2  路  3Comments

schmunk42 picture schmunk42  路  3Comments