Jump to:

5542 Posts in 1739 Topics by 1225 members

Customising the CMS

SilverStripe Forums » Customising the CMS » ModelAdmin form layout

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

Page: 1
Go to End
Author Topic: 1143 Views
  • Sphere
    Community Member
    44 Posts

    ModelAdmin form layout Link to this post

    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.

  • swaiba
    Forum Moderator
    1792 Posts

    Re: ModelAdmin form layout Link to this post

    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

  • Sphere
    Community Member
    44 Posts

    Re: ModelAdmin form layout Link to this post

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

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.