Getting label with colon for model's field in a form

I need to have Body: (with colon at the end), not Body rendered as label for each field in my form. How can I achieve this the best way?

I tried modifying fieldConfig => template in ActiveForm::begin by adding <div class=\"\">{label}:</div> into it:


<?php $form = ActiveForm::begin([

	'id' => 'edit-form',

	'options' => ['class' => 'form-horizontal'],

	'fieldConfig' => [

    	'template' => "<div class=\"\">{label}:</div>\n<div class=\"\">{input}</div>\n<div class=\"\">{error}</div>",

    	'labelOptions' => ['class' => 'edit-label'],

	],

]); ?>

but it is wrong. Colon is rendered as separate DOM element, with incorrect styling and looks just ugly.

I tried doing this awfully in CSS:


.edit-label::after { 

	content: ":";

}

but this is even worse.

I remember, that I made a lot of stupid things in Yii1 to get this. I don’t want to repeat these stupid things.

What is the best way of achieving this in Yii2?

When using Bootstrap 3 (yii\bootstrap\ActiveField) you can use additional placeholders in the $template and you need to replace {label} with {beginLabel}{labelTitle}:{endLabel}:


<?php $form = ActiveForm::begin([

	'id' => 'edit-form',

	'options' => [

    	'class' => 'form-horizontal',

    	'enctype'=>'multipart/form-data'

	],

	'fieldConfig' => [

    	'template' => "<div class=\"\">{beginLabel}{labelTitle}:{endLabel}</div>\n<div class=\"\">{input}</div>\n<div class=\"\">{error}</div>",

    	'labelOptions' => ['class' => 'edit-label'],

	],

]); ?>

I don’t know, how to solve this problem, if you’re using basic yii\widgets\ActiveField instead.