mirror of
https://github.com/silverstripe/silverstripe-userforms.git
synced 2024-10-22 17:05:42 +02:00
656a9fbb4e
- Make statics private - Use Config::get rather than eval to read private statics - Add a helper function to expose UserDefinedForm_EmailRecipient::$summary_fields (to make them available for i18n).
43 lines
944 B
PHP
Executable File
43 lines
944 B
PHP
Executable File
<?php
|
|
/**
|
|
* EditableCheckboxGroup
|
|
*
|
|
* Represents a set of selectable radio buttons
|
|
*
|
|
* @package userforms
|
|
*/
|
|
|
|
class EditableCheckboxGroupField extends EditableMultipleOptionField {
|
|
|
|
private static $singular_name = "Checkbox Group";
|
|
|
|
private static $plural_name = "Checkbox Groups";
|
|
|
|
public function getFormField() {
|
|
$optionSet = $this->Options();
|
|
$options = array();
|
|
|
|
$optionMap = ($optionSet) ? $optionSet->map('Title', 'Title') : array();
|
|
|
|
return new CheckboxSetField($this->Name, $this->Title, $optionMap);
|
|
}
|
|
|
|
public function getValueFromData($data) {
|
|
$result = '';
|
|
$entries = (isset($data[$this->Name])) ? $data[$this->Name] : false;
|
|
|
|
if($entries) {
|
|
if(!is_array($data[$this->Name])) {
|
|
$entries = array($data[$this->Name]);
|
|
}
|
|
foreach($entries as $selected => $value) {
|
|
if(!$result) {
|
|
$result = $value;
|
|
} else {
|
|
$result .= ", " . $value;
|
|
}
|
|
}
|
|
}
|
|
return $result;
|
|
}
|
|
} |