Commit 78b74de1 by dianc

File type added in category

parent 762a49eb
...@@ -139,6 +139,7 @@ class CategoryController extends Controller ...@@ -139,6 +139,7 @@ class CategoryController extends Controller
$model = $this->findModel($id); $model = $this->findModel($id);
$modelFiles = $model->categoryFiles; $modelFiles = $model->categoryFiles;
// $modelFiles->type = $modelFiles::TYPE_JS;
if ($model->load(Yii::$app->request->post())) { //&& $model->save() if ($model->load(Yii::$app->request->post())) { //&& $model->save()
...@@ -235,7 +236,7 @@ class CategoryController extends Controller ...@@ -235,7 +236,7 @@ class CategoryController extends Controller
} }
} }
return $this->render('createe', [ return $this->render('file', [
'model' => $model, 'model' => $model,
'modelFiles' => (empty($modelFiles)) ? [new CategoryFiles()] : $modelFiles 'modelFiles' => (empty($modelFiles)) ? [new CategoryFiles()] : $modelFiles
]); ]);
......
...@@ -12,18 +12,6 @@ use trntv\filekit\widget\Upload; ...@@ -12,18 +12,6 @@ use trntv\filekit\widget\Upload;
<div class="category-form"> <div class="category-form">
<?php $form = ActiveForm::begin(); ?> <?php $form = ActiveForm::begin(); ?>
<!-- <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 id="myTabContent" class="tab-content">
<div class="tab-pane fade in active" id="info"> <div class="tab-pane fade in active" id="info">
......
...@@ -4,19 +4,12 @@ ...@@ -4,19 +4,12 @@
use yii\helpers\Html; use yii\helpers\Html;
use yii\widgets\ActiveForm; use yii\widgets\ActiveForm;
use wbraganca\dynamicform\DynamicFormWidget; use wbraganca\dynamicform\DynamicFormWidget;
?> ?>
<div class="customer-form"> <div class="customer-form">
<?php $form = ActiveForm::begin(['id' => 'dynamic-form']); ?> <?php $form = ActiveForm::begin(['id' => 'dynamic-form']); ?>
<div class="row">
<div class="col-sm-6">
<?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
</div>
<div class="col-sm-6">
<?= $form->field($model, 'description')->textInput(['maxlength' => true]) ?>
</div>
</div>
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-heading"> <div class="panel-heading">
...@@ -36,7 +29,7 @@ use wbraganca\dynamicform\DynamicFormWidget; ...@@ -36,7 +29,7 @@ use wbraganca\dynamicform\DynamicFormWidget;
'formFields' => [ 'formFields' => [
'name', 'name',
'code', 'code',
'category_id', 'type',
], ],
]); ?> ]); ?>
...@@ -46,25 +39,31 @@ use wbraganca\dynamicform\DynamicFormWidget; ...@@ -46,25 +39,31 @@ use wbraganca\dynamicform\DynamicFormWidget;
<div class="panel-heading"> <div class="panel-heading">
<h3 class="panel-title pull-left">Category Files</h3> <h3 class="panel-title pull-left">Category Files</h3>
<div class="pull-right"> <div class="pull-right">
<button type="button" class="add-item btn btn-success btn-xs"><i class="glyphicon glyphicon-plus"></i></button> <button type="button" class="add-item btn btn-success btn-xs"><i
<button type="button" class="remove-item btn btn-danger btn-xs"><i class="glyphicon glyphicon-minus"></i></button> class="glyphicon glyphicon-plus"></i></button>
<button type="button" class="remove-item btn btn-danger btn-xs"><i
class="glyphicon glyphicon-minus"></i></button>
</div> </div>
<div class="clearfix"></div> <div class="clearfix"></div>
</div> </div>
<div class="panel-body"> <div class="panel-body">
<?php <?php
// necessary for update action. // necessary for update action.
if (! $modelFile->isNewRecord) { if (!$modelFile->isNewRecord) {
echo Html::activeHiddenInput($modelFile, "[{$i}]category_id"); echo Html::activeHiddenInput($modelFile, "[{$i}]category_id");
} }
?> ?>
<div class="row"> <div class="row">
<div class="col-sm-5"> <div class="col-sm-4">
<?= $form->field($modelFile, "[{$i}]name")->textInput(['maxlength' => true]) ?> <?= $form->field($modelFile, "[{$i}]name")->textInput(['maxlength' => true]) ?>
</div> </div>
<div class="col-sm-5"> <div class="col-sm-4">
<?= $form->field($modelFile, "[{$i}]code")->textInput(['maxlength' => true]) ?> <?= $form->field($modelFile, "[{$i}]code")->textInput(['maxlength' => true]) ?>
</div> </div>
<div class="col-sm-4">
<!-- <?//= $form->field($modelFile, "[{$i}]type")->textInput(['maxlength' => true]) ?> -->
<?= $form->field($modelFile, "[{$i}]type")->dropDownList($modelFile::getfiles(), ['prompt' => '']) ?>
</div>
</div> </div>
</div> </div>
</div> </div>
...@@ -75,7 +74,7 @@ use wbraganca\dynamicform\DynamicFormWidget; ...@@ -75,7 +74,7 @@ use wbraganca\dynamicform\DynamicFormWidget;
</div> </div>
<div class="form-group"> <div class="form-group">
<?= Html::submitButton( 'Save', ['class' => 'btn btn-primary']) ?> <?= Html::submitButton('Save', ['class' => 'btn btn-primary']) ?>
</div> </div>
<?php ActiveForm::end(); ?> <?php ActiveForm::end(); ?>
......
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