Yii2 model relation not working -
other model data not showing in gridview.
i have 2 models,listforms , lists. want show list name lists on listforms gridview. code.
listforms model:
class listforms extends \yii\db\activerecord{ // relation name public $listname; /** * @inheritdoc */ public static function tablename() { return 'listforms'; } public function getlistname() { return $this->hasone(lists::classname(), ['listid' => 'listids']); }
listforms gridview:
[ 'label'=>'list name', 'attribute' => 'listname', 'value' => 'listname.listname' ],
listformssearch:
public function search($params){ $query = listforms::find(); $query->joinwith(['listname']); //... }
remove
public $listname;
from model, because declare variable in model not taken database , shown. not work in lot of places.
Comments
Post a Comment