Open nagyt234 opened 9 years ago
You need to parse the POST and model values correctly and convert any boolean or string to int.
Hi @kartik-v !,
Its not really solved when the checkbox is unchecked, if you don't return the modified valuem then the label is not updated because in the source code is wrong => $input.val()
this not return if its checked or not, it should be done using $input.prop('checked')
There are 6 $input.val()
in the source code:
https://github.com/kartik-v/yii2-editable/blob/master/src/assets/js/editable.js#L201
https://github.com/kartik-v/yii2-editable/blob/master/src/assets/js/editable.js#L223
...
As a temporary workarorund i'm doing
function editableSuccess(event, val, form, data){ // display label from checkbox if($(event.currentTarget).closest('.kv-editable').find('.tb-checkbox-editable').length==1){ var isChecked = $(event.currentTarget).closest('.kv-editable').find('.tb-checkbox-editable input[type="checkbox"]').prop('checked') var value = isChecked ? 1 : 0; var displayValue = $(event.currentTarget).closest('.kv-editable').find('.tb-checkbox-editable input[type="checkbox"]').attr('data-translate-' + value) setTimeout( function(){ $(event.currentTarget).closest('.kv-editable').find('.kv-editable-value').html(displayValue) }, 100) } }
By the way, I've added a css class as well in the configuration:
... 'inlineSettings' => [ 'options' => [ 'class' => 'card panel panel-default ' . $tbCssClass, ], ....
Thanks!
Thanks for the update. Could you submit a PR for this?
I'm using the following column in GridView::widget:
It works perfectly, however if in the edit form the checkbox status is changed from checked to unchecked, the controller is called, the value of
is_calculated
in the database is set to false (0), the JSON call returns HTML OK, but the value in the grid is not updated.If the checkbox status is changed from unchecked to checked, it works perfectly.