checkboxyii2kartik-v

Kartik Editable Checkbox does not show default value as checked


I am using Kartik/Editable of latest version. Implemented a checkbox popup which works, but it does not show the default value as checked/unchecked. Example:

echo Editable::widget([
   'name' => 'test',
   'value' => 1,
   'asPopover' => false,
   'inputType'=>Editable::INPUT_CHECKBOX,
]);

This will show a popover where the checkbox is not checked at all, but it should be as value = 1. According to Kartiks documentation, the value should be an integer, not boolean.

Am I missing something? Or is this by design?


Solution

  • You should add 'options' => ['checked' => true,], for checkbox checked.

    Editable::widget([
            'name' => 'test',
            'value' => 1,
            'asPopover' => false,
            'options' => ['checked' => true,],
            'inputType' => Editable::INPUT_CHECKBOX,
    ]);