name = $name;
parent::__construct($items);
Requirements::css(SAPPHIRE_DIR . '/css/SelectionGroup.css');
}
/**
* Return a readonly version of this field. Keeps the composition but returns readonly
* versions of all the children
*/
public function performDisabledTransformation($trans) {
$newChildren = array();
$clone = clone $this;
if($clone->children) foreach($clone->getChildren() as $idx => $child) {
if(is_object($child)) {
$child = $child->transform($trans);
}
$newChildren[$idx] = $child;
}
$clone->setChildren(new FieldList($newChildren));
$clone->setReadonly(true);
return $clone;
}
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() {
Requirements::javascript(THIRDPARTY_DIR .'/jquery/jquery.js');
Requirements::javascript(SAPPHIRE_DIR . '/javascript/SelectionGroup.js');
Requirements::css(SAPPHIRE_DIR . '/css/SelectionGroup.css');
return $this->renderWith($this->template);
}
}