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

Display result of map class in two columns (admin panel)


Go to End


4 Posts   980 Views

Avatar
Derith

Community Member, 2 Posts

26 January 2017 at 11:37pm

Good morning,
I am new with SilverStripe and I have a stupid problem I don't know how to solve. I have this code:

$map = Skill::get()->sort('Name', 'ASC')->map('ID', 'Name');
$fields->addFieldToTab('Root.Covered', new CheckboxSetField($name = "Skills", $title = "Select Covered", $source = $map));

The problem is that the result of that get is to long for display just in one column in admin panel, I would like to display en two columns.

Any tip?

Avatar
martimiz

Forum Moderator, 1391 Posts

8 February 2017 at 10:24am

I don't think there's an out of the box solution. Two things I can think of are

1. Check the HTML and see if you can add some styling that would accomplish something like this. You can add a stylesheet to the cms from config.yml, someting like:

LeftAndMain:
  extra_requirements_css:
    - mysite/css/cmscustomstyle.css

2. Create a new CustomCheckboxField extends CheckboxField and give it its own template. You could give it a function that calculates the number of options and then use that value in the template. But that may be a bit complex if you're just starting...

Avatar
Derith

Community Member, 2 Posts

8 February 2017 at 10:14pm

Thanks martimiz! The second solutions worked perfect!

Avatar
martimiz

Forum Moderator, 1391 Posts

9 February 2017 at 2:32am

Great!

Just for the record (and anyone else reading this) I meant extending CheckboxSetField - not CheckboxField...