name = $name;
parent::__construct($items);
Requirements::css(FRAMEWORK_DIR . '/css/SelectionGroup.css');
}
function FieldSet() {
return $this->FieldList();
}
function FieldList() {
$items = parent::FieldList()->toArray();
$count = 0;
$firstSelected = $checked ="";
foreach($items as $key => $item) {
if(strpos($key,'//') !== false) {
list($key,$title) = explode('//', $key,2);
} else {
$title = $key;
}
if($this->value == $key) {
$firstSelected = " class=\"selected\"";
$checked = " checked=\"checked\"";
}
$itemID = $this->ID() . '_' . (++$count);
$extra = array(
"RadioButton" => "name\" value=\"$key\"$checked />",
"RadioLabel" => "",
"Selected" => $firstSelected,
);
if(is_object($item)) $newItems[] = $item->customise($extra);
else $newItems[] = new ArrayData($extra);
$firstSelected = $checked ="";
}
return new ArrayList($newItems);
}
function hasData() {
return true;
}
function FieldHolder($properties = array()) {
Requirements::javascript(THIRDPARTY_DIR .'/jquery/jquery.js');
Requirements::javascript(FRAMEWORK_DIR . '/javascript/SelectionGroup.js');
Requirements::css(FRAMEWORK_DIR . '/css/SelectionGroup.css');
$obj = $properties ? $this->customise($properties) : $this;
return $obj->renderWith($this->getTemplates());
}
}