I am writing on the YII2 framework. There is a controller in which there is a code transmitting in view the data that is in the table.
Controller:
public function actionView($id) { // Создаем модель $modelquest = new SQuizQuestion(); // Получаем все вопросы $question = SQuizQuestion::find()->all(); // Формируем массив, с ключем равным полю 'ID_REC' и значением равным полю 'NAME_QUEST' $items = ArrayHelper::map($question,'ID_REC','NAME_QUEST'); return $this->render('view', [ 'modelquest' => $modelquest, 'items' => $items, ]); } VIEW:
<div role="tabpanel" class="tab-pane fade active" id="home"> <div class="row"> <div class="col-lg-5"> <select id="list-assigned" multiple size="20" style="width: 100%"> **ВОТ СЮДА НАДО ИХ ВЫВЕСТИ** </select> </div> </div> </div> If I output this way (1):
<select id="list-assigned" multiple size="20" style="width: 100%"> <?php foreach ($modelquest as $item):?> <option value=""><? echo $item['NAME_QUEST'];?></option> <?php endforeach; ?> </select> It turns out that the records are not visible, but you can click on the lines where they should be located.
If I print it like this (2):
<select id="list-assigned" multiple size="20" style="width: 100%"> <?= Html::activeDropDownList($modelquest, 'ID_REC', $items) ?> </select> That records are displayed under the column in which they should be located. Please tell me how to display them in the column so that they are visible and clickable as in the 1st version.
