kartik-v / yii2-editable

An enhanced editable widget for Yii 2.0 that allows easy editing of displayed data with html inputs, widgets and more.
http://demos.krajee.com/editable
Other
112 stars 55 forks source link

Editable in Kartik Detailview didn't parse JSON #189

Closed kevingatp closed 5 years ago

kevingatp commented 5 years ago

I'm trying to use this widget in Kartik DetailView as inline row editable. So I set this in my view.php

    echo DetailView::widget([
        'model' => $model,
        'condensed' => true,
        'hover' => true,
        'mode' => DetailView::MODE_VIEW,
        'panel' => [
            'heading' => 'CLASS # ' . $busClassName,
            'type' => DetailView::TYPE_INFO,
        ],
        'attributes' => [            
            [
                'class' => 'kartik\grid\EditableColumn',
                'attribute' => 'busFleetStatus',
                'format' => 'raw',
                'value' => Editable::widget([
                    'model' => $model,
                    'attribute' => 'busFleetStatus',
                    'beforeInput' => function($form, $widget) {
                        echo $form->field($widget->model, 'busFleetStatus')->widget(\kartik\select2\Select2::classname(), [
                            'data' => ArrayHelper::map(SystemStatus::find()->where(['statusCode' => 'busFleetStatus'])->all(), 'systemStatusId', 'statusDetail'),
                            'options' => [                                
                                'placeholder' => 'Select Status'
                            ]
                        ])->label(false);
                    },
                    'size' => 'lg',
                    'header' => 'Bus Fleet Status',
                    'displayValueConfig' => [
                        1 => 'Operating',
                        2 => 'Maintenance',
                    ],
                    'placement' => 'right',
                    'format' => Editable::FORMAT_LINK,
                    'inputType' => Editable::INPUT_SELECT2,
                    'formOptions' => [
                        'action' => ['view', 'id' => $model->busFleetId],                                                    
                    ]
                ]),
            ],
        ],
    ])
    ?>

Based on demo, after edit the data in editable and click submit/save/apply, the view will parse data in JSON datatype into controller with method POST like this git3

But mine didn't, it showed error message git2

and from then I check in inspect element, I got this git1 there's no JSON data parse like image above, and mine use method GET as the default method of view action.

I only followed instruction like from here, but I got this issue.

  1. What's wrong with my code?
  2. Does the method GET affect this, if yes how do I can change it? I've try by edit in controller behaviors with added 'delete' => ['POST'],, but I don't what else to do so it failed.
stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.