2016-11-11 122 views
1

我有一個當前顯示覆選框列表的活動窗體,但我希望它能垂直顯示它們。我已經設置了形式佈局,垂直的,但它仍然橫向顯示出來:垂直顯示yii2複選框列表

這是我曾嘗試:

//generates an array of permissions 
$options = Permission::value_list(
    Permission::findWhere()->select('name')->andWhere(['not', ['name' => $name]])->all(), 
     ['name'] 
    ); 

這是形式

<?php $form = ActiveForm::begin(['layout' => 'vertical']); ?> 
    <?= $form->field($model, 'item_children') 
     ->checkboxList($options)->label(sprintf("Available %s", $assigning)) 
     ->hint("Which type of authorization item are you creating") ?> 

什麼我需要添加:目前它們以這種方式顯示。

enter image description here

我想垂直顯示。

+0

爲什麼你不使用CSS來做到這一點? –

+0

好主意生病嘗試, –

回答

1

你可以使用這裏提到的separator選項:http://www.yiiframework.com/doc-2.0/yii-helpers-basehtml.html#activeCheckboxList()-detail

您的來電則是這樣的,例如:

<?php $form = ActiveForm::begin(['layout' => 'vertical']); ?> 
    <?= $form->field($model, 'item_children') 
     ->checkboxList($options, ['separator'=>'<br/>']) 
     ->label(sprintf("Available %s", $assigning)) 
     ->hint("Which type of authorization item are you creating") ?> 

或任何你想作爲分隔符的使用你的具體案例。

希望有助於...

0

要使用的標籤請注意,這不會被編碼。

<?php $form = ActiveForm::begin(['layout' => 'vertical']); ?> 
     <?= $form->field($model, 'country') 
      ->inline(true) 
      ->checkboxList($options)->label(sprintf("Available %s", $assigning)) 
      ->hint("Which type of authorization item are you creating") ?> 
+0

仍然顯示他們水平我想他們的表情 –

+1

問題正在發生與標籤我相信這一點,你可以給那個css – Jigar7521

+0

好主意生病嘗試 –