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.

Customising the CMS

ModelAdmin form layout


3 Posts   1155 Views


1 February 2011 at 5:07am Community Member, 44 Posts

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.


1 February 2011 at 6:39am Forum Moderator, 1796 Posts

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 :)


1 February 2011 at 11:31pm Community Member, 44 Posts

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