Есть таблица template с полями id, templete_id - (это foren key на id этой же таблицы)
В модели у меня так:
Код: Выделить всё
public function getChildren()
{
return $this->hasMany(self::className(), ['template__id' => 'id']);
}
public function fields()
{
return ArrayHelper::merge(parent::fields(), ['children']);
}