我想通过下拉菜单渲染另一个视图。在此之前,我正在使用here中wbraganca的嵌套动态表单
这是说明图:
这是我的代码:
_formCreate.php
:
<?php DynamicFormWidget::begin([
...
]); ?>
<div class="container-items"><!-- widgetContainer -->
<?php foreach ($modelsPertanyaan as $i => $modelPertanyaan): ?>
<div class="item panel panel-default"><!-- widgetBody -->
<div class="panel-heading">
<h3 class="panel-title pull-left">Pertanyaan</h3>
<div class="pull-right">
<button type="button" class="add-item btn btn-success btn-xs"><i class="glyphicon glyphicon-plus"></i></button>
<button type="button" class="remove-item btn btn-danger btn-xs"><i class="glyphicon glyphicon-minus"></i></button>
</div>
<div class="clearfix"></div>
</div>
<div class="panel-body">
<div class="row">
<div class="col-sm-6">
<?= $form->field($modelPertanyaan, "[{$i}]nama")->textInput([
'maxlength' => true,
'placeholder' => 'Masukkan pertanyaan',
])->label('Pertanyaan') ?>
</div>
<div class="col-sm-6">
<?= $form->field($modelPertanyaan, "[{$i}]tipe")->dropDownList(
ArrayHelper::map(TipePertanyaan::find()->all(), 'tipe_pertanyaan_id', 'nama'), [
'prompt' => '- Pilih tipe pertanyaan -',
]) ?>
</div>
<div class="col-sm-6">
<!-- RENDER ANOTHER VIEW -->
<?= $this->render('_formCreateJawaban', [
'form' => $form,
'i' => $i,
'modelsJawaban' => $modelsJawaban[$i],
]) ?>
</div>
</div><!-- .row -->
</div>
</div>
<?php endforeach; ?>
</div>
<?php DynamicFormWidget::end(); ?>
而且,下拉菜单的不同更改将呈现另一种视图。
我该如何解决?