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:

Customising the CMS /

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

ModelAdmin form layout

Go to End

3 Posts   1748 Views


Community Member, 46 Posts

1 February 2011 at 5:07am

I want my form lay-out to be nice and straight.

It's for the opening-hours of my customer, and he wants something like this:
opening closing
Monday [input] [input]
tuesday [input] [input]

You get the point.

Problem is, with just field grouping, the fields aren't aligned straight in one line (quite ugly)

Anyone got a clue on how to render these fields as in a table?

I've tried "hacking" a table in by editing the labels, but that only ends up with just as skewed fields.


Forum Moderator, 1899 Posts

1 February 2011 at 6:39am

in the ModelAdmin::init....



.MangoFieldGroup {margin-bottom:10px;clear:both;height:55px;}
.MangoFieldGroup .field, .MangoFieldGroup .field label, .MangoFieldGroup .field div{display:block;float:left;clear:none;width:80px;} 

in your dataobject, surrounding the fields to be grouped

$fields->insertBefore(new LiteralField('MangoFieldGroup'.$strStartField,'<div class="MangoFieldGroup">'),$strStartField);
$fields->insertAfter(new LiteralField('MangoFieldGroup'.$strEndField,'</div>'),$strEndField);

not the cleanest of solutions, but it does work :)


Community Member, 46 Posts

1 February 2011 at 11:31pm

It's cleaner then my "solution" in any way, so :D thnx.