ActiveForm field render order


I was debuging a space between a checkbox, it’s label and a text hint and then I found out that when rendering the hints for the checkbox Yii Bootstrap ActiveForm is rendering it in a different order then a text input field with hint enabled. Chek this out.

<?= $form->field($article, 'title')->hint('Textfield Hint') ?>

<?= $form->field($article, 'active')->checkbox()->hint('Checkbox Hint') ?>

The following HTML code is rendered:

<div class="form-group field-article-tittle required">

<label class="control-label" for="article-title">Title</label>

<input type="text" id="article-title" class="form-control" name="Article[title]" value="">

<p class="help-block">Textfield Hint</p>

<p class="help-block help-block-error"></p>


<div class="form-group field-article-active">

<div class="checkbox">

<label for="article-active">

<input type="hidden" name="Article[active]" value="0"><input type="checkbox" id="article-active" name="Article[active]" value="1" checked="">



<p class="help-block help-block-error"></p>

<p class="help-block">Checkbox Hint</p>



For the text field, the comes after the hint and for the checkbox, the comes before the hint.

The generated HTML should be consistent, I mean, blocks should be rendered in the same order.

I’m reporting this because I’m having problems setting the margins for the “p”. The hint for a text field appears closer to it then the hint for a checkbox because the have a margin-bottom that push the hint down.

I oppened an issue for this: