Esempio n. 1
0
?>

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

    <?php 
echo $form->field($model, 'content')->textarea(['rows' => 6]);
?>

    <?php 
echo $form->field($model, 'tags')->textarea(['rows' => 6]);
?>
    
    <?php 
echo $form->field($model, 'status')->dropDownList(Poststatus::find()->select(['name', 'id'])->orderBy('position')->indexBy('id')->column(), ['prompt' => '请选择状态']);
?>

	<?php 
echo $form->field($model, 'author_id')->dropDownList(User::find()->select(['username', 'id'])->indexBy('id')->column(), ['prompt' => '请选择作者']);
?>
    		   
    <div class="form-group">
        <?php 
echo Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
    </div>

    <?php 
ActiveForm::end();
?>
Esempio n. 2
0
use yii\helpers\Html;
use yii\grid\GridView;
use common\models\Poststatus;
/* @var $this yii\web\View */
/* @var $searchModel common\models\PostSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Yii::t('app', 'Posts');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="post-index">

    <h1><?php 
echo Html::encode($this->title);
?>
</h1>
    <?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>

    <p>
        <?php 
echo Html::a(Yii::t('app', 'Create Post'), ['create'], ['class' => 'btn btn-success']);
?>
    </p>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], ['attribute' => 'id', 'contentOptions' => ['width' => '30px']], 'title', 'tags:ntext', ['attribute' => 'username', 'label' => '作者', 'value' => 'author.username'], ['attribute' => 'status', 'value' => 'status0.name', 'filter' => Poststatus::find()->select(['name', 'id'])->orderBy('position')->indexBy('id')->column()], ['attribute' => 'update_time', 'format' => ['date', 'php:Y-m-d H:i:s']], ['class' => 'yii\\grid\\ActionColumn']]]);
?>
</div>
Esempio n. 3
0
 /**
  * 对应文章状态表(1对1)
  */
 public function getStatus0()
 {
     return $this->hasOne(Poststatus::className(), ['id' => 'status']);
 }