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.

General Questions

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

Add HR into tab in admin


4 Posts   1311 Views


6 May 2009 at 6:57am Community Member, 197 Posts

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

6 May 2009 at 10:40am Community Member, 604 Posts

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.



6 May 2009 at 5:32pm Forum Moderator, 5511 Posts

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.


6 May 2009 at 11:19pm Community Member, 197 Posts

Thank you.

I combined your answers to create this working code:

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