yiisoft / yii2-gii

Yii 2 Gii Extension
http://www.yiiframework.com
BSD 3-Clause "New" or "Revised" License
202 stars 192 forks source link

Gii generated ActiveField checkbox does not render template correctly? #210

Open yii-bot opened 8 years ago

yii-bot commented 8 years ago

This issue has originally been reported by @wangchj at https://github.com/yiisoft/yii2/issues/6439. Moved here by @wangchj.


The following is Gii generate form in PHP

<?= $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() ?>

The following is the HTML output. Notice, it doesn't resemble the template.

<div class="form-group field-loginform-rememberme">
    <div class="checkbox">
        <label>
        <input type="hidden" name="LoginForm[rememberMe]" value="0">
        <input type="checkbox" id="loginform-rememberme" name="LoginForm[rememberMe]" value="1" checked>
        Remember Me
        </label>
        <p class="help-block help-block-error"></p>
    </div>
</div>
mayankpal100 commented 6 years ago

<?= $form->field($model, 'active')->checkbox(['template' => "<div class=\"togglebutton\">

{error}"]); ?>

This work in yii2

mayankpal100 commented 6 years ago

and for input field use this ->

`<?= $form->field($model, 'a_line_about_project',['template'=> '

{input}
{error}'])->textInput(['maxlength' => true]) ?>`
Abiraman commented 6 years ago

Use like this`<?= $form->field($model, 'recomended_by_user', ['template'=>'

                            </div>'])->textInput(['class'=>"",'type'=>'checkbox'])?>`