Commit 1a7272ce by jomon

code review changes

parent 71b55384
...@@ -12,35 +12,31 @@ use yii\widgets\ActiveForm; ...@@ -12,35 +12,31 @@ use yii\widgets\ActiveForm;
<?php $form = ActiveForm::begin(); ?> <?php $form = ActiveForm::begin(); ?>
<div id="myTabContent" class="tab-content">
<div class="tab-pane fade in active" id="info">
<div class="page-header">
<h3>Info</h3>
</div>
<div class="row"> <div class="row">
<div class="col-md-6"> <div class="col-md-6">
<?php echo $form->field($model, 'name')->textInput(['maxlength' => true]) ?> <?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col-md-6"> <div class="col-md-6">
<?php echo $form->field($model, 'slug')->textInput(['maxlength' => true]) ?> <?= $form->field($model, 'slug')->textInput(['maxlength' => true]) ?>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col-md-3"> <div class="col-md-3">
<?= $form->field($model, 'status')->dropDownList($model::statuses()) ?> <?= $form->field($model, 'status')->dropDownList($model::statuses()) ?>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<?= Html::submitButton($model->isNewRecord ? Yii::t('backend', 'Create') : Yii::t('backend', <?= Html::submitButton($model->isNewRecord ? Yii::t('backend', 'Create') : Yii::t('backend',
'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
</div>
</div>
</div> </div>
......
...@@ -10,6 +10,7 @@ use yii\grid\GridView; ...@@ -10,6 +10,7 @@ use yii\grid\GridView;
$this->title = Yii::t('backend', 'States'); $this->title = Yii::t('backend', 'States');
$this->params['breadcrumbs'][] = $this->title; $this->params['breadcrumbs'][] = $this->title;
?> ?>
<div class="state-index"> <div class="state-index">
<h1><?= Html::encode($this->title) ?></h1> <h1><?= Html::encode($this->title) ?></h1>
...@@ -18,6 +19,7 @@ $this->params['breadcrumbs'][] = $this->title; ...@@ -18,6 +19,7 @@ $this->params['breadcrumbs'][] = $this->title;
<p> <p>
<?= Html::a(Yii::t('backend', 'Create State'), ['create'], ['class' => 'btn btn-success']) ?> <?= Html::a(Yii::t('backend', 'Create State'), ['create'], ['class' => 'btn btn-success']) ?>
</p> </p>
<?= GridView::widget([ <?= GridView::widget([
'dataProvider' => $dataProvider, 'dataProvider' => $dataProvider,
'filterModel' => $searchModel, 'filterModel' => $searchModel,
...@@ -41,4 +43,5 @@ $this->params['breadcrumbs'][] = $this->title; ...@@ -41,4 +43,5 @@ $this->params['breadcrumbs'][] = $this->title;
['class' => 'yii\grid\ActionColumn'], ['class' => 'yii\grid\ActionColumn'],
], ],
]); ?> ]); ?>
</div> </div>
...@@ -37,7 +37,6 @@ class State extends \yii\db\ActiveRecord ...@@ -37,7 +37,6 @@ class State extends \yii\db\ActiveRecord
[ [
'class' => SluggableBehavior::className(), 'class' => SluggableBehavior::className(),
'attribute' => 'name', 'attribute' => 'name',
'immutable' => true
], ],
[ [
'class' => TimestampBehavior::className(), 'class' => TimestampBehavior::className(),
...@@ -91,6 +90,10 @@ class State extends \yii\db\ActiveRecord ...@@ -91,6 +90,10 @@ class State extends \yii\db\ActiveRecord
return new \common\models\query\StateQuery(get_called_class()); return new \common\models\query\StateQuery(get_called_class());
} }
/**
* List all status
* @return array
*/
public static function statuses() public static function statuses()
{ {
return [ return [
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
namespace common\models\query; namespace common\models\query;
use common\models\State;
/** /**
* This is the ActiveQuery class for [[\common\models\State]]. * This is the ActiveQuery class for [[\common\models\State]].
* *
...@@ -31,4 +33,9 @@ class StateQuery extends \yii\db\ActiveQuery ...@@ -31,4 +33,9 @@ class StateQuery extends \yii\db\ActiveQuery
{ {
return parent::one($db); return parent::one($db);
} }
public function active()
{
return $this->andWhere(['status' => State::STATUS_ACTIVE]);
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment