Yii2'de bir uygulama geliştiriyorum. Ben aynı sonucu yazdırmak istiyorum "SingleView" görünümü dosyasındaYii2: Güncelleme/ekleme formunda dropDown adları nasıl görüntülenir?
<!-- 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');
?>
: Aşağıdaki açılan yapısı ile formunu yaptı.
<?= 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]
],
]) ?>
ben değer bölümüne bir işlevi yazmak çalıştı ama bana bir hata verdi: "HTML özel karakter bir nesne girişi var".
Bunu yapmanın en basit yolu nedir?
'Ben değer bölümüne bir işlevi yazmak çalıştı ama bana bir error' verdi - verebilir size Bu işlevin kodunu gönderilsin mi? –