2017-02-14 1 views
1

Was ich tun möchte, ist von Bootstrap vertikalen in die horizontale Form zu ändern, und das ist, was ich versucht habe:Yii2 Horizontale Form

<?php $form = ActiveForm::begin([ 
    'layout' => 'horizontal', 
    'action' => ['index'], 
    'method' => 'get', 
    'fieldConfig' => [ 
     'horizontalCssClasses' => [ 
      'label' => 'col-sm-2', 
      'offset' => 'col-sm-offset-2', 
      'wrapper' => 'col-sm-4', 
     ], 
    ], 
]); ?> 
    <div class="row"> 
     <div class="col-md-6"> 
      <?= $form->field($model, 'firstname') ?> 
      <?= $form->field($model, 'lastname') ?> 
     </div> 
     <div class="col-md-6"> 
      <?= $form->field($model, 'email') ?> 
      <?= $form->field($model, 'bla') ?> 
     </div> 
    </div> 
<?php ActiveForm::end() ?> 

aber es gab mir einen Fehler einstellen unbekannte Eigenschaft: yii \ Widgets \ ActiveForm :: Layout Bitte helfen Sie !!!

+0

Versuchen Sie: 'Optionen' => ['Klasse' => 'Form-horizontal'], –

+0

Es funktioniert nicht –

Antwort

2

In Bootstrap können Sie

verwenden
<form class="form-inline"> // for inline fields form 

oder

<form class="form-horizontal"> // for horizonatal fields form 

zB:

<?php $form = ActiveForm::begin([ 
     'layout' => 'horizontal', 
     'action' => ['index'], 
     'method' => 'get', 
     'class' => 'form-horizontal',  
    ]); ?> 
1

Für layout Option ActiveForm arbeiten müssen Instanz yii\bootstrap\ActiveForm statt yii\widgets\ActiveForm sein.

Ändern Sie Ihre use Anweisung.

Verwandte Themen