?> <div class="books-index"> <h1><?php echo Html::encode($this->title); ?> </h1> <?php echo $this->render('_search', ['model' => $searchModel]); ?> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => null, 'columns' => ['id', 'name', ['attribute' => 'preview', 'format' => 'html', 'value' => function ($data) { return Html::a(Html::img(Image::thumb($data['preview'], 100)), $data['preview'], ['class' => 'preview_pic']); }], ['attribute' => 'author_id', 'format' => 'html', 'label' => 'Автор', 'value' => function ($data) { return $data['author']['firstname'] . ' ' . $data['author']['lastname']; }], ['attribute' => 'date', 'format' => ['date', 'php:d F Y']], 'date_create:relativeTime', ['class' => 'yii\\grid\\ActionColumn', 'template' => '{update}{view}{delete}', 'buttons' => ['format' => 'raw', 'update' => function ($url, $model) { return Html::a('<span class="glyphicon glyphicon-pencil"></span>', $url, ['title' => 'Редактировать', 'class' => 'ajax_table fancybox.ajax']); }, 'view' => function ($url, $model) { return Html::a('<span class="glyphicon glyphicon-eye-open"></span>', $url, ['title' => 'Просмотр', 'class' => 'ajax_table fancybox.ajax']); }]]]]); ?> <p> <?php echo Html::a(Yii::t('app', 'Добавить книгу'), ['create'], ['class' => 'btn btn-success']); ?> </p>
echo $form->field($model, 'author_id')->dropDownList(ArrayHelper::map(Authors::getAllAuthors(), 'id', 'name'), ['prompt' => Yii::t('app', 'Выберите автора')]); ?> <?php echo $form->field($model, 'name')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'date_fabr')->widget(DatePicker::className(), ['language' => 'ru', 'clientOptions' => ['autoclose' => true, 'format' => 'dd/mm/yyyy'], 'options' => ['placeholder' => '12/31/2014']]); ?> <?php if ($model->preview) { ?> <img src="<?php echo Image::thumb($model->preview, 240); ?> "> <a href="<?php echo Url::to(['/books/admin/clear-image', 'id' => $model->primaryKey]); ?> " class="text-danger confirm-delete" title="<?php echo Yii::t('app', 'Clear image'); ?> "><?php echo Yii::t('app', 'Clear image'); ?> </a> <?php } ?>
/* @var $model app\modules\books\models\Books */ $this->title = $model->name; $this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Books'), 'url' => ['index']]; $this->params['breadcrumbs'][] = $this->title; ?> <div class="books-view"> <h1><?php echo Html::encode($this->title); ?> </h1> <?php if (!Yii::$app->request->isAjax) { ?> <p> <?php echo Html::a(Yii::t('app', 'Update'), ['update', 'id' => $model->id], ['class' => 'btn btn-primary']); ?> <?php echo Html::a(Yii::t('app', 'Delete'), ['delete', 'id' => $model->id], ['class' => 'btn btn-danger', 'data' => ['confirm' => Yii::t('app', 'Are you sure you want to delete this item?'), 'method' => 'post']]); ?> </p> <?php } ?> <?php echo DetailView::widget(['model' => $model, 'attributes' => ['id', ['attribute' => 'author_id', 'format' => 'html', 'label' => 'Автор', 'value' => $model->author->firstname . ' ' . $model->author->lastname], 'name', ['attribute' => 'date', 'format' => ['date', 'php:d F Y']], 'date_create:relativeTime', ['attribute' => 'preview', 'format' => 'html', 'value' => Html::img(Image::thumb($model->preview, 240))]]]); ?> </div>