Exemplo n.º 1
0
 public function getAuthor()
 {
     return self::hasOne(AuthorModel::className(), ['id' => 'author_id']);
 }
Exemplo n.º 2
0
<?php

use frontend\models\AuthorModel;
use kartik\date\DatePicker;
use yii\helpers\ArrayHelper;
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model frontend\models\BookSearchModel */
/* @var $form ActiveForm */
$items = [];
foreach (AuthorModel::find()->all() as $author) {
    $items[$author->id] = $author->lastname . ' ' . $author->firstname;
}
?>
<div class="site-search">

    <?php 
$form = ActiveForm::begin();
?>

        <?php 
echo $form->field($model, 'name');
?>
        <?php 
echo $form->field($model, 'author')->dropDownList($items, ['prompt' => ' - check author - ']);
?>

        <?php 
echo $form->field($model, 'from')->widget(DatePicker::className(), ['name' => 'dp_2', 'type' => DatePicker::TYPE_COMPONENT_PREPEND, 'pluginOptions' => ['autoclose' => true]]);
?>
Exemplo n.º 3
0

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

    <?php 
echo $form->field($model, 'imageFile')->widget(FileInput::classname(), ['pluginOptions' => ['showPreview' => true, 'showCaption' => true, 'showRemove' => false, 'showUpload' => false, 'initialPreview' => $image], 'options' => [['accept' => 'image/*']]]);
?>

    <?php 
echo $form->field($model, 'date')->widget(DatePicker::className(), ['name' => 'dp_2', 'type' => DatePicker::TYPE_COMPONENT_PREPEND, 'pluginOptions' => ['autoclose' => true]]);
?>

    <?php 
echo $form->field($model, 'author_id')->dropDownList(ArrayHelper::map(AuthorModel::find()->all(), 'id', 'lastname'), ['prompt' => ' - check author - ']);
?>


    <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>