name = $name;
parent::__construct($items);
Requirements::css(FRAMEWORK_DIR . '/css/SelectionGroup.css');
}
public function FieldSet() {
return $this->FieldList();
}
public function FieldList() {
$items = parent::FieldList()->toArray();
$count = 0;
$firstSelected = $checked ="";
$newItems = array();
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);
}
public function hasData() {
return true;
}
public 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());
}
}