Jump to:

23377 Posts in 18296 Topics by 2868 members

General Questions

SilverStripe Forums » General Questions » SS3 Gridfield buttons-before-left fragment missing

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

Page: 1
Go to End
Author Topic: 647 Views
  • BlueO
    Avatar
    Community Member
    52 Posts

    SS3 Gridfield buttons-before-left fragment missing Link to this post

    Hi there, I've been playing around with GridField in SS3 and found a problem I'm not sure how to address.

    I have the following model : 'Page' -- has_one --> 'Block' --has_many--> 'Contents'

    I can successfully add a gridfield to manage the 'Page' -- has_one --> 'Block' relationship but as soon as I add the second 'Block' --has_many--> 'Contents' Relationship I get this error:

    Error at \framework\forms\gridfield\GridField.php line 291: Uncaught LogicException: GridField HTML fragment 'buttons-before-left' was given content, but not defined. Perhaps there is a supporting GridField component you need to add?

    Now I can get around that error by adding a $DefineFragment(buttons-before-left) somewhere in one of the GridField templates Eg \framework\templates\Includes\GridFieldToolbarHeader.ss It seesm to be adding the 'autocompleter' section.

    Then it works well.... but this is obviously a slightly hacky way to do things - is there a better one? Have I just missed the correct procedure?

    cheers

    b

  • e-scape
    Avatar
    Community Member
    16 Posts

    Re: SS3 Gridfield buttons-before-left fragment missing Link to this post

    b

    Sorry not an answer, but I do have a question.. you say that you have a working has_one relation managed via GridField. Would you mind sharing that code as I am struggling to find references to this setup anywhere, its all 1-many and many-many.

    Many thanks
    Jason

  • BlueO
    Avatar
    Community Member
    52 Posts

    Re: SS3 Gridfield buttons-before-left fragment missing Link to this post

    sure thing:
    NB I belive the previous problem has been addressed since I posted last!

    but a has one i've mostly managed with a dropdown field (I can't recall my original setup unfortunately) but if you really wanted i guess you could use something like this:
    untested so mileage may vary...

    class SideBar extends DataObject {

    static $db = array(
    'Type' => 'Enum("SideItem,EducationSearchWidget,GoogleMapWidget","SideItem")',
    'Title' => 'Varchar'
    );
    static $has_one =array(
    'Style' => 'Style'
    );

    function getCMSFields() {
    parent::getCMSFields();

    $fields = new FieldList(
    new TextField('Title')

    );
    $sc = Style::get()->filter(array("ID" => "Style.ID"));
    $GridField = new GridField("Style", "Styles on this page", $sc, new GridFieldConfig_RelationEditor());
    $fields->push($GridField);

    return $fields;
    }


    }

    647 Views
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.