-
-
Notifications
You must be signed in to change notification settings - Fork 190
Closed
Description
This issue has originally been reported by @Stevad at yiisoft/yii2#6312.
Moved here by @cebe.
What I try to do:
- create own ActiveField class with changed
templateandhorizontalCssClasses
namespace app\components;
class ActiveField extends \yii\bootstrap\ActiveField
{
public $template = "{label}\n{beginWrapper}\n{input}\n{error}\n{hint}\n{endWrapper}";
public $horizontalCssClasses = [
'offset' => 'col-sm-offset-3',
'label' => 'col-sm-3',
'wrapper' => 'col-sm-6',
'error' => '',
'hint' => '',
];
}- then I use my class in ActiveForm:
<?php $form = ActiveForm::begin([
'fieldClass' => 'app\components\ActiveField',
'layout' => 'horizontal'
]); ?>
...But if I dump some field like $form->field($model, 'name') I see that template and horizontalCssClasses not changed (their values are default from native \yii\bootstrap\ActiveField).
Dump:
object(app\components\ActiveField)[136]
public 'template' => string '{label}
{beginWrapper}
{input}
{error}
{endWrapper}
{hint}' (length=58)
public 'horizontalCssClasses' =>
array (size=5)
'offset' => string 'col-sm-offset-3' (length=15)
'label' => string 'col-sm-3' (length=8)
'wrapper' => string 'col-sm-6' (length=8)
'error' => string '' (length=0)
'hint' => string 'col-sm-3' (length=8)
public 'inline' => boolean false
public 'inputTemplate' => null
...
instead of
object(app\components\ActiveField)[136]
public 'template' => string '{label}
{beginWrapper}
{input}
{error}
{hint} <-- hint before endWrapper
{endWrapper}' (length=58)
public 'horizontalCssClasses' =>
array (size=5)
'offset' => string 'col-sm-offset-3' (length=15)
'label' => string 'col-sm-3' (length=8)
'wrapper' => string 'col-sm-6' (length=8)
'error' => string '' (length=0)
'hint' => string '' (length=0) <-- hint value must be empty
public 'inline' => boolean false
public 'inputTemplate' => null
...
I think this is error in \yii\bootstrap\ActiveField class.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
type:bugBugBug