Yii2 获取型号为'的冒号标签;表单中的s字段

Yii2 获取型号为'的冒号标签;表单中的s字段,yii2,Yii2,我需要有Body:(结尾带冒号),而不是Body作为表单中每个字段的标签呈现。我怎样才能以最好的方式实现这一点 我尝试在ActiveForm::begin中修改fieldConfig=>template,在其中添加div class=\“\”>{label}:: <?php $form = ActiveForm::begin([ 'id' => 'edit-form', 'options' => ['class' => 'form-horizontal']

我需要有
Body:
(结尾带冒号),而不是
Body
作为表单中每个字段的标签呈现。我怎样才能以最好的方式实现这一点

我尝试在
ActiveForm::begin
中修改
fieldConfig=>template
,在其中添加
div class=\“\”>{label}:

<?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'],
]]); ?>
但这更糟糕

我记得,为了得到这个,我做了很多愚蠢的事情。我不想重复这些愚蠢的事情,当我在Yii2中实现它的时候。实现这一目标的最佳方式是什么

使用Bootstrap 3()时,可以在
$template
中使用其他占位符,并且需要将
{label}
替换为
{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'],
    ],
]); ?>

我不知道,如果你用basic来代替,如何解决这个问题

<?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'],
    ],
]); ?>