yii2 active field template

Herokiller picture Herokiller · Nov 6, 2014 · Viewed 25.9k times · Source

It seems template for checkbox in sample yii2 project doesn't not apply correctly

<?= $form->field($model, 'rememberMe', [
    'template' => "<div class=\"col-lg-offset-1 col-lg-3\">{input}</div>\n<div class=\"col-lg-8\">{error}</div>",
])->checkbox() ?>

what's wrong here?

Answer

ustmaestro picture ustmaestro · Dec 9, 2014

You need to pass template like in this example

<?= $form->field($model, 'rememberMe')
->checkbox(
['template' => '<div class="form-group">{input}<label class="control-label">{label}</label></div>']
) ?>