1 <?php
2 3 4 5 6 7 8
9
10 class EditableCheckboxGroupField extends EditableMultipleOptionField {
11
12 static $singular_name = "Checkbox Group";
13
14 static $plural_name = "Checkbox Groups";
15
16 function getFormField() {
17 $optionSet = $this->Options();
18 $options = array();
19
20 $optionMap = ($optionSet) ? $optionSet->map('Title', 'Title') : array();
21
22 return new CheckboxSetField($this->Name, $this->Title, $optionMap);
23 }
24
25 function getValueFromData($data) {
26 $result = '';
27 $entries = (isset($data[$this->Name])) ? $data[$this->Name] : false;
28
29 if($entries) {
30 if(!is_array($data[$this->Name])) {
31 $entries = array($data[$this->Name]);
32 }
33 foreach($entries as $selected => $value) {
34 if(!$result) {
35 $result = $value;
36 } else {
37 $result .= ", " . $value;
38 }
39 }
40 }
41 return $result;
42 }
43 }
[Raise a SilverStripe Framework issue/bug](https://github.com/silverstripe/silverstripe-framework/issues/new)
- [Raise a SilverStripe CMS issue/bug](https://github.com/silverstripe/silverstripe-cms/issues/new)
- Please use the
Silverstripe Forums to ask development related questions.
-