View Issue Details

This bug affects 1 person(s).
 10
IDProjectCategoryView StatusLast Update
10986Bug reportsPluginspublic2016-05-24 09:49
Reporterakeyser Assigned ToDenisChenu  
PriorityhighSeveritypartial_block 
Status closedResolutionfixed 
Product Version2.50.x 
Fixed in Version2.50.x 
Summary10986: Survey-specific plugin setting of type "checkbox" does not properly save
Description

We are creating a plugin that uses a "checkbox" type of field in its survey-specific settings.

LimeSurvey is not saving the status of this checkbox upon saving the survey general settings.

When a checkbox is used in the plugin's global settings, however, it does save properly.

TagsNo tags attached.
Attached Files
checkboxTest.php (1,492 bytes)   
<?php

/**
 * User: akeyser
 */
class CheckboxTest extends PluginBase
{
    protected $storage = 'DbStorage';
    static protected $name = "Checkbox Test";
    static protected $description = "Test Plugin for Survey-Specific Checkbox Settings";

    /**
     * @param PluginManager $manager
     * @param int $id
     */
    public function __construct(PluginManager $manager, $id)
    {
        parent::__construct($manager, $id);
        $this->subscribe('beforeSurveySettings');
        $this->subscribe('newSurveySettings');
    }

    /**
     * This event is fired by the administration panel to gather extra settings
     * available for a survey.
     * The plugin should return setting meta data.
     * @internal param PluginEvent $event
     */
    public function beforeSurveySettings()
    {
        $event = $this->event;
        $event->set("surveysettings.{$this->id}", [
            'name' => get_class($this),
            'settings' => [
                'checkboxTest' => [
                    'type' => 'checkbox',
                    'label' => 'Checkbox',
                    'current' => $this->get('checkboxTest', 'Survey', $event->get('survey'))
                ]
            ]
        ]);
    }

    /**
     * Save the settings
     */
    public function newSurveySettings()
    {
        $event = $this->event;
        foreach ($event->get('settings') as $name => $value) {
            $this->set($name, $value, 'Survey', $event->get('survey'));
        }
    }
}
checkboxTest.php (1,492 bytes)   
Bug heat10
Complete LimeSurvey version number (& build)160418
I will donate to the project if issue is resolvedNo
BrowserGoogle Chrome 49
Database type & versionMySQL 5.6.27-log
Server OS (if known)Windows Server 2008 R2
Webserver software & version (if known)IIS 7.5
PHP Version5.6.14

Users monitoring this issue

There are no users monitoring this issue.

Activities

ollehar

ollehar

2016-04-20 11:36

administrator   ~37584

Please attach your plugin.

akeyser

akeyser

2016-04-20 16:16

reporter   ~37619

I will create a plugin that specifically demonstrates this issue. I may be able to get this to you in a few hours.

akeyser

akeyser

2016-04-20 23:17

reporter   ~37621

Okay, I can slightly re-define this issue now.

Initially, the checkbox appears as empty. However, once enabled and saved, any further attempt to disable the checkbox and save results in the value still being "true" or "1", so the checkbox stays checked after the settings are saved.

Attaching the plugin.

c_schmitz

c_schmitz

2016-05-17 14:32

administrator   ~38632

It looks like the same even is fired twice on survey save.
Denis, may you have a look?

DenisChenu

DenisChenu

2016-05-17 14:39

developer   ~38633

Last edited: 2016-05-19 11:48

<s>Seems new, last time i tested : work OK (and seems top work on 2.06)</s>

OK : checkbox is not in post request : the none is send.

sammousa

sammousa

2016-05-19 15:50

reporter   ~38686

akeyser, while your issue is valid. In general I would recommend using setting type "boolean" instead.

It is more abstract (it describes the setting not how it is displayed) and gives a theme developer more control. (For example for booleans one could use: checkbox, radio, dropdown, bootstrap toggle switches and so on).

This is unrelated to us fixing the issue though :)

DenisChenu

DenisChenu

2016-05-19 15:59

developer   ~38687

Fix committed to master branch: http://bugs.limesurvey.org/plugin.php?page=Source/view&amp;id=19096

DenisChenu

DenisChenu

2016-05-19 16:03

developer   ~38688

Fix committed to 2.06lts branch: http://bugs.limesurvey.org/plugin.php?page=Source/view&amp;id=19097

DenisChenu

DenisChenu

2016-05-19 17:03

developer   ~38690

Thanks to sammousa (and Yii)

c_schmitz

c_schmitz

2016-05-24 09:49

administrator   ~38749

Version 2.50+ Build 160523 released

Related Changesets

LimeSurvey: master c9535b08

2016-05-19 13:59:16

DenisChenu

Details Diff
Fixed issue 10986: Plugin survey setting type "checkbox" does not properly save Affected Issues
10986
mod - application/extensions/SettingsWidget/SettingsWidget.php Diff File

LimeSurvey: 2.06lts fa6a8013

2016-05-19 14:02:57

DenisChenu

Details Diff
Fixed issue 10986: Plugin survey setting type "checkbox" does not properly save
Dev: cherry-pick have conflict ...
Affected Issues
10986
mod - application/extensions/SettingsWidget/SettingsWidget.php Diff File

Issue History

Date Modified Username Field Change
2016-04-19 19:22 akeyser New Issue
2016-04-20 11:36 ollehar Note Added: 37584
2016-04-20 11:36 ollehar Assigned To => ollehar
2016-04-20 11:36 ollehar Status new => feedback
2016-04-20 16:16 akeyser Note Added: 37619
2016-04-20 16:16 akeyser Status feedback => assigned
2016-04-20 23:17 akeyser Note Added: 37621
2016-04-20 23:18 akeyser File Added: checkboxTest.php
2016-05-17 14:32 c_schmitz Assigned To ollehar => DenisChenu
2016-05-17 14:32 c_schmitz Note Added: 38632
2016-05-17 14:32 c_schmitz Priority none => high
2016-05-17 14:39 DenisChenu Note Added: 38633
2016-05-19 11:48 DenisChenu Note Edited: 38633
2016-05-19 15:50 sammousa Note Added: 38686
2016-05-19 15:59 DenisChenu Changeset attached => LimeSurvey master c9535b08
2016-05-19 15:59 DenisChenu Note Added: 38687
2016-05-19 15:59 DenisChenu Resolution open => fixed
2016-05-19 16:03 DenisChenu Changeset attached => LimeSurvey 2.06lts fa6a8013
2016-05-19 16:03 DenisChenu Note Added: 38688
2016-05-19 17:03 DenisChenu Note Added: 38690
2016-05-19 17:03 DenisChenu Status assigned => resolved
2016-05-19 17:03 DenisChenu Fixed in Version => 2.5
2016-05-24 09:49 c_schmitz Note Added: 38749
2016-05-24 09:49 c_schmitz Status resolved => closed