Commit 31be3fa5 by dianc

Category Info and Files Tab

parent 921e71b3
......@@ -64,6 +64,8 @@ class CategoryController extends Controller
{
$model = new Category();
$model->status = $model::STATUS_ACTIVE;
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
} else {
......
......@@ -12,54 +12,75 @@ use trntv\filekit\widget\Upload;
<div class="category-form">
<?php $form = ActiveForm::begin(); ?>
<?= $form->errorSummary($model); ?>
<ul id="myTab" class="nav nav-tabs">
<li class="active">
<a href="#info" data-toggle="tab">
Info
</a>
</li>
<li>
<a href="#files" data-toggle="tab">
Files
</a>
</li>
</ul>
<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="col-md-3">
<?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
<div class="col-md-6">
<?php echo $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
</div>
</div>
<div class="row">
<div class="col-md-3">
<?= $form->field($model, 'slug')->textInput(['maxlength' => true]) ?>
<div class="col-md-6">
<?php echo $form->field($model, 'slug')->textInput(['maxlength' => true]) ?>
</div>
</div>
<div class="row">
<div class="col-md-3">
<?= $form->field($model, 'description')->textarea(['maxlength' => true]) ?>
<div class="col-md-6">
<?php echo $form->field($model, 'description')->textarea(['rows' => '7']) ?>
</div>
</div>
<div class="row">
<div class="col-md-3">
<?= $form->field($model, 'image')->widget(Upload::className(), [
'url' => ['/file-storage/upload'],
])->label('Image');
<div class="row">
<div class="col-md-6">
<?= $form->field($model, 'image')->widget(
Upload::className(),
[
'url' => ['/file-storage/upload'],
])->label('Image');
?>
</div>
</div>
<div class="row">
<div class="col-md-3">
<div class="row">
<div class="col-md-6">
<?= $form->field($model, 'status')->dropDownList($model::statuses(), ['prompt' => '']) ?>
</div>
</div>
<div class="form-group">
<?= Html::submitButton($model->isNewRecord ? Yii::t('backend', 'Create') : Yii::t('backend', 'Update'),
['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
<div class="form-group">
<?php echo Html::submitButton($model->isNewRecord ? Yii::t('backend', 'Create') : Yii::t('backend', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
</div>
</div>
<div class="tab-pane fade in" id="files">
<div class="page-header">
<h3>Files</h3>
</div>
</div>
<?php ActiveForm::end(); ?>
</div>
</div>
<?php
$config = [
'name'=>'Yii2 Starter Kit',
'name'=>'Libromi Web',
'vendorPath'=>dirname(dirname(__DIR__)).'/vendor',
'extensions' => require(__DIR__ . '/../../vendor/yiisoft/extensions.php'),
'sourceLanguage'=>'en-US',
......
......@@ -44,7 +44,7 @@ class Category extends \yii\db\ActiveRecord
public function rules()
{
return [
[['name', 'slug', 'status'], 'required'],
[['name', 'status'], 'required'],
[['status', 'created_at', 'updated_at'], 'integer'],
[['name', 'slug'], 'string', 'max' => 32],
[['description'], 'string', 'max' => 512],
......
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