diff --git a/forms/CheckboxSetField.php b/forms/CheckboxSetField.php index c4bed6cbe..7cafc2661 100644 --- a/forms/CheckboxSetField.php +++ b/forms/CheckboxSetField.php @@ -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); + } } } diff --git a/tests/forms/CheckboxSetFieldTest.php b/tests/forms/CheckboxSetFieldTest.php index 609084782..ac4bc22d6 100644 --- a/tests/forms/CheckboxSetFieldTest.php +++ b/tests/forms/CheckboxSetFieldTest.php @@ -1,9 +1,11 @@ "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' );