<?php use yii\helpers\Html; use yii\grid\GridView; use app\models\Category; use app\models\Post; /* @var $this yii\web\View */ /* @var $searchModel app\models\PostSearch */ /* @var $dataProvider yii\data\ActiveDataProvider */ $this->title = '文章管理'; $this->params['breadcrumbs'][] = $this->title; ?> <div class="box post-index"> <div class="box-header with-border"> <?php echo Html::a('发表新文章', ['create'], ['class' => 'btn btn-success']); ?> </div> <div class="box-body"> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'tableOptions' => ['class' => 'table table-bordered table-hover'], 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'title', ['attribute' => 'cid', 'value' => 'postCategory', 'filter' => Html::activeDropDownList($searchModel, 'cid', ['' => '全部'] + Category::getAllCategories(), ['class' => 'form-control'])], ['attribute' => 'author_id', 'value' => function ($model, $key, $index, $column) { return $model->author ? $model->author->nickname : null; }], ['attribute' => 'is_top', 'format' => 'html', 'value' => function ($model, $key, $index, $column) { return $model->is_top ? '<span class="label label-success">置顶</span>' : ''; }, 'filter' => Html::activeDropDownList($searchModel, 'is_top', ['' => '全部', '0' => '否', '1' => '是'], ['class' => 'form-control'])], ['attribute' => 'status', 'value' => 'postStatus', 'filter' => Html::activeDropDownList($searchModel, 'status', ['' => '全部'] + Post::getAvailableStatus(), ['class' => 'form-control'])], ['attribute' => 'comment_count', 'filter' => false], ['attribute' => 'view_count', 'filter' => false], ['attribute' => 'post_time', 'format' => ['date', 'php:Y-m-d H:i:s'], 'filter' => false], ['class' => 'yii\\grid\\ActionColumn', 'template' => '{view} {update}']]]); ?> </div> </div>
echo $form->field($model, 'author_name')->textInput(['maxlength' => true]); ?> </div> </div> <?php echo $form->field($model, 'cover', ['template' => '{label}<div class="input-group"><span class="input-group-btn"><button id="cover-upload" type="button" class="btn btn-success">上传图片</button></span>{input}</div>'])->textInput(['maxlength' => true]); ?> <div class="row"> <div class="col-md-12 col-lg-3"> <?php echo $form->field($model, 'cid')->dropDownList(Category::getAllCategories()); ?> </div> <div class="col-md-12 col-lg-3"> <?php echo $form->field($model, 'status')->dropDownList(Post::getAvailableStatus()); ?> </div> <div class="col-md-12 col-lg-3"> <?php echo $form->field($model, 'type')->dropDownList(Post::getAvailableType()); ?> </div> <div class="col-md-12 col-lg-3"> <?php echo $form->field($model, 'is_top')->dropDownList(['0' => '普通', '1' => '置顶']); ?> </div> </div> <?php echo $form->field($model, 'content')->textarea(['rows' => 6])->widget(UEditor::className(), ['config' => ['serverUrl' => ['editor/index'], 'iframeCssUrl' => Yii::getAlias('@web') . '/static/css/ueditor.css']]);