How to get values of independent table

Following code will give me back an array of all foreignKeys,which are in table:





    public static function fk_for_adresses() {

        $auswahl = Ekontakt::find()->select('id_person')->all();

        return yii\helpers\ArrayHelper::map($auswahl, 'id_person', 'id_person');

    }



Following code will give back all values of table Person,where Primarykey(id)=ForeignKey(id_person), instead only one for each display line(see attachement). Any ideas,what I do wrong?





    [

        'attribute' => $wird_dargestellt_fuer,

        'label' => Yii::t('app', 'gehört zu'),

        'format' => 'html',

        'value' => function($model) {

            $namen = "";

            $eKontakte = Ekontakt::fk_for_adresses();

            $model = Person::find()->where(['id' => $eKontakte])->all();

            foreach ($model as $Kontakt) {

                $namen .= "<div id=''><ul><li><span class='glyphicon glyphicon-earphone'></span>" . $Kontakt->vorname . "," . $Kontakt->nachname;

            }

            $namen .= "</div></ul></li>";

            return $namen;

        }

    ],

.

.






'value' => function($model) {



This won’t help,'cause I have not model, which I can use in function in this case. $model is not the right one, 'cause I am rendering two models in Controller.

I nevertheless followed ur advice, without any effect,of course(see above)

This variation will show up the same thing:





   [

        'attribute' => $wird_dargestellt_fuer,

        'label' => Yii::t('app', 'gehört zu'),

        'format' => 'html',

        'value' => function($model) {

            $namen = "";

            $eKontakte = Ekontakt::fk_for_adresses();

            $fk_member = array();

            $y = 0;

            foreach ($eKontakte as $kontakt) {

                $fk_member[$y] = $kontakt;

                $y++;

            }

            for ($i = 0; $i < count($fk_member); $i++) {

                $model = Person::find()->where(['id' => $fk_member[$i]])->all();


                foreach ($model as $kontakte) {

                    $namen .= "<div id=''><ul><li><span class='glyphicon glyphicon-earphone'></span>" . $kontakte->vorname . "," . $kontakte->nachname;

                }

            }

            $namen .= "</div></ul></li>";


            return $namen;

        }

    ],



This thread has been canceled. It’s no longer up to date