-2

I have a navbar menu in my views folder ( menu.php ) I was called this menu in my supplier view (supplier.php) because i need to high-lite the selected menu item.

code in supplier.php

<?= $this->render('menu', ['currentpage'=>'Suppliers']); ?>

<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
?>

<?php $form = ActiveForm::begin(); ?>

<?= $form->field($model, 'Type')->dropDownList([ 'Individual' => 'Individual', 'Registered' => 'Registered', ], ['prompt' => '']) ?>

<?= $form->field($model, 'Licence_no')->textInput(['maxlength' => true]) ?>

<?= $form->field($model, 'Name')->textInput(['maxlength' => true]) ?>

<?= $form->field($model, 'Address')->textInput(['maxlength' => true]) ?>

<?= $form->field($model, 'Estate')->textInput(['maxlength' => true]) ?>

<?= $form->field($model, 'Acreage')->textInput() ?>

<?= $form->field($model, 'NIC')->textInput(['maxlength' => true]) ?>

<?= $form->field($model, 'Tel')->textInput() ?>

<div class="form-group">
    <?= 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(); ?>

menu.php coding (refer to 'active' => ($currentpage == 'Suppliers'))

<?php
use kartik\sidenav\SideNav;
?>

<div class="row">
        <div class="col-xs-5 col-sm-4 col-lg-3">
            <?= SideNav::widget([
            'type' => SideNav::TYPE_DEFAULT,
            'heading' => 'System Functions',
            'items' => [
                [
                    'url' => '../dashboard/manager',
                    'label' => Yii::t('app','Dashboard'),
                    'icon' => 'home',   
                    'active' => ($currentpage == 'Manager')
                ],
                [
                    'url' => '#',
                    'label' => 'Purchase',
                    'icon' => 'home',                       
                     'items' => [
                            [
                              'url' => '../dashboard/suppliers',
                              'label' => Yii::t('app','Suppliers'), 
                              'icon'=>'glyphicon transport',                                
                              'active' => ($currentpage == 'Suppliers')
                            ],
                            [
                                'url' => '../dashboard/leaf-entry',
                                'label' => 'Leaf Collection', 
                                'icon'=>'leaf', 
                                'active' => ($currentpage == 'Leaf')
                            ],
                            [
                                'url' => '../dashboard/payments',
                                'label' => 'Payments', 
                                'icon'=>'phone', 
                                'active'=> ($currentpage == 'Payments') 
                            ],
                            ['label' => 'Reports', 'icon'=>'phone', 'url'=>'#']
                     ],
                ],
                [
                    'label' => 'Stock',
                    'icon' => 'question-sign',
                    'items' => [
                        ['label' => 'Live Stock', 'icon'=>'info-sign', 'url'=>'#'],
                        ['label' => 'Auction Despatch', 'icon'=>'phone', 'url'=>'#'],
                        ['label' => 'Production Tracker', 'icon'=>'phone', 'url'=>'#'],
                        ['label' => 'Reports', 'icon'=>'phone', 'url'=>'#']
                      ],
                ],
                [
                    'label' => 'Human Resource',
                    'icon' => 'question-sign',
                    'items' => [
                        ['label' => 'Employees', 'icon'=>'info-sign', 'url'=>'#'],
                        ['label' => 'Time Tracker', 'icon'=>'phone', 'url'=>'#'],
                        ['label' => 'Payments', 'icon'=>'phone', 'url'=>'#'],
                        ['label' => 'Reports', 'icon'=>'phone', 'url'=>'#']
                      ],
                ],
                    ],
                ]);
            ?>
        </div>       
</div>

controller function

public function actionSuppliers()
{
    $this->layout = 'DashboardLayout';   

     $model = new LeafSupplier();

    if ($model->load(Yii::$app->request->post()) && $model->save()) {
        //return $this->redirect(['view', 'id' => $model->Supplier_id]);
    } else {
       return $this->render('suppliers',[
                                'model' => $model,
                            ], 
                            [ 'currentpage' => 'Suppliers']);
    }
}

Highlighted 'suppliers' menu item

enter image description here

After all this modifications form field can't editable. can't type any values it's disabled. once i comment out this render('menu', ['currentpage'=>'Suppliers']); ?> form fields can editable.

commented code in supplier.php

enter image description here

after commented the render method fields are editable.

enter image description here

asela daskon
  • 356
  • 1
  • 5
  • 19
  • Not enough information... There is nothing wrong with that part of menu. The problem is elsewhere. – Clyff Jan 18 '16 at 14:26
  • you were wrong. can you see the code 'render('menu', ['currentpage'=>'Suppliers'])' in my supplier.php file. when i comment this out from the page i can type value into the form. otherwise can't – asela daskon Jan 18 '16 at 14:32
  • Again, there is nothing wrong with that part of menu. The problem is elsewhere. This item by it self won't cause the issue. You made something wrong in another part of your menu.php. Still not enough information. – Clyff Jan 18 '16 at 14:51
  • you don't get it. tell me what else do you need to show. nothing wrong with the menu and coding. but i found that render command have some issue. it won't allow to type in the form – asela daskon Jan 18 '16 at 15:07
  • Did you read my comment? I just answered this. – Clyff Jan 18 '16 at 15:11
  • I was added more info – asela daskon Jan 18 '16 at 15:55
  • Try to avoid using `render()` inside your view. I suggest that you create your own widget with that menu inside widget view. – Deele Jan 19 '16 at 23:57
  • can you give me your suggestions using the code snippet ? – asela daskon Jan 20 '16 at 02:47

1 Answers1

1

Finally i was found the answer to this question. I have used Karthik ActiveForm widget by eliminate the Yii2 default ActiveFrom widget. now i can type values into the field.

Thanks everyone's reply.

asela daskon
  • 356
  • 1
  • 5
  • 19