FIX: Allow empty checkboxes through setValue(null) (#1392)

This commit is contained in:
Will Rossiter 2014-01-12 17:28:09 +13:00
parent 13bd4e96b1
commit e7266535c5
2 changed files with 20 additions and 2 deletions

View File

@ -90,8 +90,13 @@ class CheckboxSetField extends OptionsetField {
if($values instanceof SS_List || is_array($values)) {
$items = $values;
} else {
$items = explode(',', $values);
$items = str_replace('{comma}', ',', $items);
if($values === null) {
$items = array();
}
else {
$items = explode(',', $values);
$items = str_replace('{comma}', ',', $items);
}
}
}

View File

@ -1,9 +1,11 @@
<?php
/**
* @package framework
* @subpackage tests
*/
class CheckboxSetFieldTest extends SapphireTest {
protected static $fixture_file = 'CheckboxSetFieldTest.yml';
protected $extraDataObjects = array(
@ -144,7 +146,13 @@ class CheckboxSetFieldTest extends SapphireTest {
}
/**
* @package framework
* @subpackage tests
*/
class CheckboxSetFieldTest_Article extends DataObject implements TestOnly {
private static $db = array(
"Content" => "Text",
);
@ -155,7 +163,12 @@ class CheckboxSetFieldTest_Article extends DataObject implements TestOnly {
}
/**
* @package framework
* @subpackage tests
*/
class CheckboxSetFieldTest_Tag extends DataObject implements TestOnly {
private static $belongs_many_many = array(
'Articles' => 'CheckboxSetFieldTest_Article'
);