私はYii2でアプリケーションを開発しています。Yii2:更新/挿入フォームにdropDownの名前を表示するにはどうすればいいですか?
<!-- Konténer típus -->
<?= $form->field($model, 'kontener_tipus_id')
->dropDownList(
ArrayHelper::map(KontenerTipus::find()->AsArray()->all(), 'id',
function($model, $defaultValue) {
if ($model['tipus'] == "N") { $tipus = "Nyitott"; } else { $tipus = "Zárt"; };
if ($model['forma'] == "S") { $forma = "Szimmetrikus forma"; } else { $forma = "Aszimmetrikus forma"; };
if ($model['lancos'] == 0) { $lancos = "Láncos"; } else { $lancos = "Nem láncos"; };
if ($model['teto'] == "B") { $teto = "Billenő tetős"; } else { $teto = "Pille tetős"; };
return $tipus . " - " . $forma . " - " . $lancos . " - " . $teto;
}
)
)
->label('Konténer típus');
?>
"SingleView"ビューファイルでは、同じ結果を出力したいと思います。
<?= DetailView::widget([
'model' => $model,
'attributes' => [
'id',
'kod',
'nev',
'cim',
'kihelyezes_datuma',
'lng',
'lat',
['attribute' => 'sajat', 'value' => $model->getSajat()],
//Konténer típushoz tartozó tulajdonságok megjelenítése
['attribute' => 'kontener_tipus_id', 'value' => 11]
],
]) ?>
値のセクションに関数を書き込もうとしましたが、「HTMLの特殊文字にオブジェクト入力があります」というエラーが表示されました。
これを行う最も簡単な方法は何と思いますか?
'私は、値セクションに関数を記述しようとしたが、それは私にERROR'を与えた - あなたの可能性この関数のコードを投稿しますか? –