Jump to:

22972 Posts in 11596 Topics by 2824 members

General Questions

SilverStripe Forums » General Questions » Add HR into tab in admin

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Page: 1
Go to End
Author Topic: 1213 Views
  • DeklinKelly
    Avatar
    Community Member
    196 Posts

    Add HR into tab in admin Link to this post

    I have created a custom tab in the admin.

    I would like to place a divider or <hr /> between sections.

    Can this be done?

    Attached Files
  • Double-A-Ron
    Avatar
    Community Member
    599 Posts

    Re: Add HR into tab in admin Link to this post

    I'm not sure if this is the best way, but the HeaderField field type works well for me when I need to insert any custom HTML into the CMS forms.

    In your case, in your getCMSFields function of the Page, you would add a HeaderField in the relevant position like so:

    ....
    $fields->push( new TextField( 'Item1Link', 'Item 1 Link' ));
    $fields->push( new HeaderField( '<hr />', '3', true ) );
    $fields->push( new TextField( 'Item2Title', 'Item 2 Title' ));
    ....

    The first argument is the HTML you want to insert. The second is the Header size (not relevant in this case), and the third is to tell the method to allow HTML in the first argument.

    http://api.silverstripe.com/forms/fields-dataless/HeaderField.html

    Cheers
    Aaron

  • Willr
    Avatar
    Forum Moderator
    5462 Posts

    Re: Add HR into tab in admin Link to this post

    Rather then a header field - which is designed for Header elements (<h1>) a better one would be the LiteralField() which is designed to just output whatever you pass it.

  • DeklinKelly
    Avatar
    Community Member
    196 Posts

    Re: Add HR into tab in admin Link to this post

    Thank you.

    I combined your answers to create this working code:

    $fields->addFieldToTab("Root.Content.Item", new LiteralField('CustomCode1','<hr />'));

    1213 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.