public function actionDeleteCategory()
 {
     $masterCategory = new MasterCategory();
     if (\Yii::$app->request->post('category_id') != '') {
         $masterCategory->deleteCategory(\Yii::$app->request->post('category_id'));
         return $this->redirect(['index']);
     }
 }
Example #2
0
        <div class="modal-body">
              <?php 
$form = ActiveForm::begin(['id' => 'category-form', 'enableAjaxValidation' => false, 'enableClientValidation' => true]);
?>
                <div class="form-group"> 
                    <label>Category Name <span style="color:red"> *</span></label>
                        <?php 
echo Html::activeTextInput($masterCategory, 'category_name', ['class' => 'form-control input-lg', 'placeholder' => '']);
//field
echo Html::error($masterCategory, 'category_name', ['id' => 'category_name', 'class' => 'errorMessage help-block']);
//error
?>
                </div>
                <div class="form-group"> 
                    <?php 
echo $form->field($masterCategory, 'parent_id')->dropDownList(MasterCategory::getcategoryList(), ['class' => 'form-control selectpicker', 'data-live-search' => 'true', 'prompt' => 'None']);
?>
                    
                    
                </div>
                <div class="clearfix"></div>
                <div class="form-group m-t-10 m-b-0">
                    <button type="button" class="btn btn-primary" onclick="saveCategory()">Submit</button>&nbsp;&nbsp;
                    <button type="submit" class="btn btn-default" data-dismiss="modal" aria-label="Close">Cancel</button>
                </div> 
            <?php 
ActiveForm::end();
?>
        </div>
    </div>
</div>