?> <?php echo $form->field($model, 'user_id')->dropDownList(ArrayHelper::map(\backend\models\User::find()->asArray()->all(), 'id', 'username')); ?> <?php echo '<label class="control-label">图片</label>'; echo FileInput::widget(['model' => $model, 'attribute' => 'logo', 'pluginOptions' => ['uploadExtraData' => ['album_id' => 20, 'cat_id' => 'Nature'], 'maxFileCount' => 10, 'initialCaption' => $model->logo, "showUpload" => false]]); ?> <?php echo $form->field($model, 'category_id')->dropDownList(ArrayHelper::map(\backend\models\Category::get(0, \backend\models\Category::find()->asArray()->all()), 'id', 'str_label')); ?> <?php echo $form->field($model, 'status')->dropDownList(\backend\models\Article::getArrayStatus()); ?> <?php echo $form->field($model, 'title')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'intro')->textarea(['rows' => 6]); ?> <?php //外部TAG echo Html::tag('script', $model->content, ['id' => Html::getInputId($model, 'content'), 'name' => Html::getInputName($model, 'content'), 'type' => 'text/plain']); echo Ueditor::widget(['model' => $model, 'attribute' => 'content', 'renderTag' => false, 'jsOptions' => ['serverUrl' => yii\helpers\Url::to(['upload']), 'autoHeightEnable' => true, 'autoFloatEnable' => true]]);
<p> <?php echo Html::a('创建', ['create'], ['class' => 'btn btn-success']); ?> </p> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], ['attribute' => 'user_id', 'value' => function ($model) { return $model->user ? $model->user->username : '******'; }], ['attribute' => 'category_id', 'value' => function ($model) { return $model->category->title; }, 'filter' => Html::activeDropDownList($searchModel, 'category_id', \backend\models\Article::getArrayCategory(), ['class' => 'form-control', 'prompt' => '请筛选'])], 'title', ['attribute' => 'status', 'format' => 'html', 'value' => function ($model) { if ($model->status === Article::STATUS_ACTIVE) { $class = 'label-success'; } elseif ($model->status === Article::STATUS_INACTIVE) { $class = 'label-warning'; } else { $class = 'label-danger'; } return '<span class="label ' . $class . '">' . $model->statusLabel . '</span>'; }, 'filter' => Html::activeDropDownList($searchModel, 'status', Article::getArrayStatus(), ['class' => 'form-control', 'prompt' => '请筛选'])], ['class' => 'yii\\grid\\ActionColumn', 'header' => '操作', 'template' => '{preview}{view}{update}{delete}{send}{unsend}', 'buttons' => ['delete' => function ($url, $model, $key) { return Html::a('<span class="glyphicon glyphicon-trash"></span>', $url, ['title' => '删除', 'data' => ['confirm' => '你确定要删除吗?', 'method' => 'post']]); }, 'send' => function ($url, $model, $key) { return $model->status == Article::STATUS_INACTIVE ? Html::a(' <span class="glyphicon glyphicon-send"></span>', $url, ['title' => '发布']) : ''; }, 'unsend' => function ($url, $model, $key) { return $model->status == Article::STATUS_ACTIVE ? Html::a(' <span class="glyphicon glyphicon-comment"></span>', $url, ['title' => '取消发布']) : ''; }]]]]); ?> </div>