1
Kartik의 DetailView 및 Select2를 사용하여 여러 선택 참석자 목록을 드롭 다운 밖으로 저장합니다. 감안Yii2 : Kartik의 DetailView 및 Select2에 저장된 값이로드되지 않습니다.
<?= $form->field($model, 'attendants')->widget(Select2::classname(), ['data' => $model->attendantList, 'options' => ['placeholder' => Yii::t('app', 'Select...'), 'multiple' => true]]) ?>
: $model->attendantList
형태는 'ID'& '이름'쌍 배열이다
[
'attribute' => 'attendants',
'format' => 'raw',
'type' => DetailView::INPUT_SELECT2,
'widgetOptions' => ['data' => $model->attendantList, 'options' => ['placeholder' => Yii::t('app', 'Select...'),'multiple' => true]],
'value' => call_user_func(function($model){
$attendants = '';
foreach($model->persons as $person) {$attendants .= Html::a($person->name, ['aux-person-event/index', 'person_id' => $person->id]).'<br/>';}
return $attendants;
}, $model),
],
.
업데이트 작업을 통해 표준 ActiveForm을 사용하는 경우 저장된 값은 업데이트시 양식에 정상적으로로드됩니다. 그러나 편집 모드에서 Kartik의 DetailView를 사용할 때는 그렇지 않습니다.
단서가 있습니까?
참석자 변수가 모델에 정의되어 있습니까? 규칙 섹션에서 언급 했습니까? – Jigar7521