Example #1
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getAuthor()
 {
     return $this->hasOne(Authors::className(), ['id' => 'author_id']);
 }
 public function safeDown()
 {
     \app\models\DataModels\Authors::deleteAll('');
 }
Example #3
0
$form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]);
?>

    <?php 
echo $form->field($model, 'name')->textInput(['maxlength' => true]);
?>

    <?php 
echo $form->field($model, 'file')->fileInput();
?>

    <?php 
echo $form->field($model, 'date')->widget(\yii\jui\DatePicker::className(), array('language' => 'ru', 'dateFormat' => 'yyyy-MM-dd'));
?>

    <?php 
echo $form->field($model, 'author_id')->dropDownList(\app\models\ArrayGenerator::generateHash(\app\models\DataModels\Authors::find()->all(), 'id', 'first_name'));
?>

    <div class="form-group">
        <?php 
echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
    </div>

    <?php 
ActiveForm::end();
?>

</div>