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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

General Questions /

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

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

Add HR into tab in admin

Go to End

4 Posts   2328 Views


Community Member, 197 Posts

6 May 2009 at 6:57am

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

Community Member, 607 Posts

6 May 2009 at 10:40am

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.



Forum Moderator, 5523 Posts

6 May 2009 at 5:32pm

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.


Community Member, 197 Posts

6 May 2009 at 11:19pm

Thank you.

I combined your answers to create this working code:

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