mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
FIX: Allow empty checkboxes through setValue(null) (#1392)
This commit is contained in:
parent
13bd4e96b1
commit
e7266535c5
@ -90,10 +90,15 @@ class CheckboxSetField extends OptionsetField {
|
||||
if($values instanceof SS_List || is_array($values)) {
|
||||
$items = $values;
|
||||
} else {
|
||||
if($values === null) {
|
||||
$items = array();
|
||||
}
|
||||
else {
|
||||
$items = explode(',', $values);
|
||||
$items = str_replace('{comma}', ',', $items);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(is_array($source)) {
|
||||
unset($source['']);
|
||||
|
@ -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'
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user