This is my view
'promoter_id' => [
'type' => Form::INPUT_DROPDOWN_LIST,
'options' => ['prompt' => '--'.Yii::t ( 'app', 'Ventor Type' ).'--',],
'items' => ArrayHelper::map (
User::find ()->orderBy ( 'username')->where(['user_type_id' => [13]])->asArray ()->all (),
'id',
'username'
)
]
What i did?
show the users filtered by user_type_id = 13
.
user_type_id=13
means the users are promoters.
What i want?
I want to show the users like below sql query using ArrayHelper::map
.
SELECT u.username
FROM tbl_user u,tbl_user_type t
where u.user_type_id = t.id and t.type='promoter';
Since you are using mysql you can simply use an
innerJoin
:If you have a relation between
user
anduser_type
you can usejoinWith
instead, which handles the join type and the join condition for you: