Answer the question
In order to leave comments, you need to log in
Yii2: How to get extraFields from associated data model?
There are two AR models: A,B. Model B connects to model A via hasOne (iata field):
 public function getIata()
    {
        return $this->hasOne(B::className(),
                        ['iata_id' => 'iata_id']);
    }
    public function extraFields()
    {
        return ['f' => function(){ return "Something"; }];
    }
$a = A::findOne(1)->toArray([], ['iata', 'f', 'iata.f', 'F'], true);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question