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

[SOLVED] Grouping SelectionGroup or Labels for SelectionGroups


Go to End


3 Posts   3439 Views

Avatar
derralf

Community Member, 28 Posts

18 March 2009 at 11:16pm

Edited: 20/03/2009 11:03am

Hello Community,

is it possible to group SelectionGroups in CMS or make a label for a SelectionGroup?
I have 2 SelectionGroups to chose options for has_many images: GalerieLayout and GalerieDisplayMode

The SelectionGroups are displaying in my tab like this:

o Columns
o Rows
o Lightbox
o Gallerific

And what i want is this:

Layout ((one SelectionGroup))
o Rows
o Columns

Display ((other SelectionGroup))
o Lightbox
o Gallerific

any ideas or hints?
thanks in advance,
Ralf

my code:

$fields->addFieldToTab('Root.Content.GalerieSettings',
		new SelectionGroup('GalerieLayout', array(
    		"rows//Rows (Standard)" => new HiddenField(""),
		"columns//Columns" => new HiddenField("")
		))
);
	
$fields->addFieldToTab('Root.Content.GalerieSettings',
		new SelectionGroup('GalerieDisplayMode', array(
    		"gallerific//Gallerific (Standard)" => new HiddenField(""),
		"lightbox//Lightbox" => new HiddenField("")
		))
);

Avatar
theAlien

Community Member, 131 Posts

20 March 2009 at 4:56am

Edited: 20/03/2009 4:58am

Hi,

I don't have any experience with selectiongroups, so I checked the API and the file in sapphire/forms/SelectionGroup.php.

As far as I understand it, there is no way to display the $name of the selectiongroup right now (in your setup it would be GallerieLayout and GallerieDisplayMode). However... there is a workaround (add it above your Layout-selectiongroup and add another one above your Display-selectiongroup)

$fields->addFieldToTab('Root.Content.GallerieSettings', new LiteralField(
    "myTitle",
    "<p style='font-size:11px; color:#444'>Layout</p>"
));

The HTML-tags are just in there to show you can do almost anything inside a LiteralField (even adding <img>-tags).

Instead of a LiteralField you could also use a LabelField, a HeaderField or one of the other Dataless/Utility form fieldtypes.

Avatar
derralf

Community Member, 28 Posts

20 March 2009 at 10:57am

Great! That will do it. And it's much more flexible...
Thanks