Jump to:

5453 Posts in 1674 Topics by 1198 members

Customising the CMS

SilverStripe Forums » Customising the CMS » [SOLVED] Grouping SelectionGroup or Labels for SelectionGroups

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

Page: 1
Go to End
Author Topic: 1733 Views
  • derralf
    Avatar
    Community Member
    24 Posts

    [SOLVED] Grouping SelectionGroup or Labels for SelectionGroups Link to this post

    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("")
          ))
    );

  • theAlien
    Avatar
    Community Member
    131 Posts

    Re: [SOLVED] Grouping SelectionGroup or Labels for SelectionGroups Link to this post

    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.

  • derralf
    Avatar
    Community Member
    24 Posts

    Re: [SOLVED] Grouping SelectionGroup or Labels for SelectionGroups Link to this post

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

    1733 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.