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've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

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

SS3 Gridfield buttons-before-left fragment missing


Go to End


3 Posts   1732 Views

Avatar
BlueO

Community Member, 52 Posts

28 May 2012 at 2:59pm

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

Avatar
Quadra

Community Member, 16 Posts

18 July 2012 at 3:50am

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

Avatar
BlueO

Community Member, 52 Posts

18 July 2012 at 10:34am

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;
   }

}