use yii\helpers\ArrayHelper; use yii\widgets\ActiveForm; use AlexanderEmelyanov\yii\modules\articles\models\Article; /* @var $this yii\web\View */ /* @var $model AlexanderEmelyanov\yii\modules\articles\models\ArticleInstance */ /* @var $form yii\widgets\ActiveForm */ ?> <div class="article-instance-form"> <?php $form = ActiveForm::begin(); ?> <?php echo $form->field($model, 'article_id')->dropDownList(ArrayHelper::map(Article::find()->all(), 'article_id', 'url_key')); ?> <?php echo $form->field($model, 'author_id')->textInput(); ?> <?php echo $form->field($model, 'language')->textInput(['maxlength' => 16]); ?> <?php echo $form->field($model, 'created_at')->textInput(); ?> <?php
/** * Finds the Article model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Article the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Article::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * @return \yii\db\ActiveQuery */ public function getArticle() { return $this->hasOne(Article::className(), ['article_id' => 'article_id']); }