Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Customising the CMS /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Grouping CheckboxsetField by ParentID (or adding headings or dividers?)


Go to End


2 Posts   872 Views

Avatar
neilcreagh

Community Member, 136 Posts

15 October 2014 at 5:11am

I'm trying to find a way to make a large CheckboxsetField display friendlier. Ideally I'd like to group them by their ParentID (with a divider, or even better, the title of each Parent ID over each set). Is there any (relatively simple) way to do something like that?

The CheckboxsetField is a collection of pages of a particular pagetype (Category) so they all have a ParentID Title

Avatar
thomas.paulson

Community Member, 107 Posts

23 October 2014 at 12:45am

Hi Neil

the best option will be create custome field by extending CheckboxSetField, like below

class MyCheckboxSetField extends CheckboxSetField{
/**
* @todo Explain different source data that can be used with this field,
* e.g. SQLMap, ArrayList or an array.
*/
public function Field($properties = array()) {
Requirements::css(FRAMEWORK_DIR . '/css/CheckboxSetField.css');
your code here
========================
$properties = array_merge($properties, array('Options' => new ArrayList($options)));
return $this->customise($properties)->renderWith($this->getTemplates());
}
}

Also create MyCheckboxSetField.ss template file.

for more info, go to framework/forms/CheckboxsetField.php and see how it is done