/** * Рендерит html районов для dropdown * @param int $id идентификатор региона * @throws \yii\base\ExitException */ public function actionRajons($id) { $all = Rajon::find()->published()->where(["region_id" => $id])->orderBy(["title" => SORT_ASC])->all(); $o = ["prompt" => ""]; echo Html::renderSelectOptions(null, ArrayHelper::map($all, "id", "title"), $o); Yii::$app->end(); }
/** * Связь с районами * @return \yii\db\ActiveQuery */ public function getRajons() { return $this->hasMany(Rajon::className(), ["region_id" => "id"])->published(); }
/** * Связь с районом * @return \yii\db\ActiveQuery */ public function getRajon() { return $this->hasOne(Rajon::className(), ["id" => "rajon_id"]); }