echo Html::encode($this->title); ?> </h1> <?php // echo $this->render('_search', ['model' => $searchModel]); ?> <?php $label = new \app\models\Books(); ?> <p> <?php echo Html::a('Новая запись', ['create'], ['class' => 'btn btn-success']); ?> </p> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'id', ['label' => $label->getAttributeLabel('book_category_id'), 'attribute' => 'book_category_id', 'format' => 'raw', 'value' => function ($data) { return \app\models\Books::getCategorys($data->book_category_id); }, 'filter' => \app\models\Books::getCategorys()], 'name', ['label' => $label->getAttributeLabel('authors'), 'attribute' => 'authors', 'format' => 'raw', 'value' => function ($data) { $author = ''; foreach (\app\models\BooksAuthors::getAuthorsName($data->authors) as $key => $val) { $author .= $val . '<BR>'; } return $author; }, 'filter' => \app\models\BooksAuthors::getAuthorsName()], 'year', 'views', ['class' => 'yii\\grid\\ActionColumn', 'header' => 'Кнопки действий', 'template' => '{view} {update} {delete}']]]); ?> </div>
<?php use yii\helpers\Html; use yii\widgets\DetailView; /* @var $this yii\web\View */ /* @var $model app\models\Books */ $this->title = $model->name; $this->params['breadcrumbs'][] = ['label' => 'Книги', 'url' => ['index']]; $this->params['breadcrumbs'][] = $this->title; ?> <div class="books-view"> <?php $label = new \app\models\Books(); ?> <h1><?php echo Html::encode($this->title); ?> </h1> <?php echo DetailView::widget(['model' => $model, 'attributes' => ['name', ['label' => $label->getAttributeLabel('authors'), 'format' => 'html', 'value' => \app\models\BooksAuthors::getAuthorsName($model->authors, true)], 'year', ['label' => $label->getAttributeLabel('annotation'), 'format' => 'html', 'value' => $model->annotation]]]); ?> </div> <div class="form-group"> <a href="/books" class="btn btn-primary">Вернуться к списку</a> </div>