KVron
(Lfparedes)
May 15, 2015, 2:35am
1
I have the following dropDownList:
[color="#000080 "]<?php [/color][color="#660000 "]$form [/color]= ActiveForm::begin b ; [/b][color="#000080 "]?> [/color]
.
.
.
[color="#000080 "]<?= [/color][color="#660000 "]$form[/color]->field( [color="#660000 "]$model[/color], [color="#008000 "]‘owners’ [/color]) ->dropDownList[b](
[/b][indent]Owner::getOwnerList b ,
[/b][/indent][indent][ [/indent][indent][indent]‘multiple’ => [color="#008000 "]‘multiple’ [/color][b],
[/b][/indent][/indent][indent]] [/indent]) [color="#000080 "]?> [/color]
I want to select a default owner by its id ([font="Courier New"]$owner_id[/font]) when creating a new [font="Courier New"][color="#a0522d "]$model[/color][/font].
The owners appear in the drop down list but how do I [font="Franklin Gothic Medium"]programmatically[/font] select the one I want?
KVron:
I have the following dropDownList:
I want to select a default owner by its id ([font="Courier New"]$owner_id[/font]) when creating a new [font="Courier New"][color="#a0522d "]$model[/color][/font].
The owners appear in the drop down list but how do I [font="Franklin Gothic Medium"]programmatically[/font] select the one I want?
in controller before post
$model->owner_id= '2';
and in view
<?= $form->field($model, 'owners')->dropDownList(
Owner::getOwnerList(),
[
'multiple' => 'multiple','initialize' =>true,
]
)?>
KVron
(Lfparedes)
May 18, 2015, 8:29pm
3
in controller before post
$model->owner_id= '2';
and in view
<?= $form->field($model, 'owners')->dropDownList(
Owner::getOwnerList(),
[
'multiple' => 'multiple','initialize' =>true,
]
)?>
Thank you rups g , that works perfectly!!