Yii2 dropDownList

1

I need an example, from dropDownList, where I can make a dropDown between two sqls, in this case A and B.

Below is a pseudocode.

Introduction to the problem:

Table sql A

id_A
id_usuario
nome_A
descricao_A

Table sql B

id_B
id_A
nome_B
descricao_B

I need to do a dropDownList with sql B, where all sql A fields that have id_usuario = 10 should be displayed, but in sql B I do not have the id_user field, it should be something like inner join, however using the dropDownList of yii2.

The syntax below, which I am using does not resolve, since it only displays the fields which satisfies id_A (sql A and B).

dropDownList(\yii\helpers\ArrayHelper::map(B::find()->where(['id_A' => $A->id_A])->all(),'id_B','nome_B') ,

P.S. I do not want to put the userid in sql B.

    
asked by anonymous 14.11.2016 / 01:04

1 answer

0

I found the solution, in the above example just make the following modification:

$id_usuario = Yii::$app->user->identity->getId();

dropDownList(\yii\helpers\ArrayHelper::map(B::find()->([A])->where(['id_usuario' => $id_usuario])->all(),'id_B','nome_B') 
    
15.11.2016 / 22:51