In yii2 I have a dropdownlist:
<?= $form->field($model, 'Körperschaft')->dropDownList(['a' => 'Item A', 'b' => 'Item B', 'c' => 'Item C'])?>
How can I set 'Item B' as a default value?
try this
<?= $form->field($model, 'Körperschaft')->dropDownList(['a' => 'Item A', 'b' => 'Item B', 'c' => 'Item C'], ['options'=>['b'=>['Selected'=>true]]])?>
I got it! The solutions is to write in the controller:
public function actionCreate()
{
$model->Körperschaft='b';
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With