Jump to:

22998 Posts in 11620 Topics by 2827 members

General Questions

SilverStripe Forums » General Questions » customsiteconfig and gridfield

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: 426 Views
  • dacar
    Avatar
    Community Member
    168 Posts

    customsiteconfig and gridfield Link to this post

    Hi,
    can anybody explain, how to use the gridfield within a custom siteconfig?

    The following will throw an error (PHP Fatal error: Call to undefined method CustomSiteConfig::Mitarbeiter()):

             $mitarbeiterField = new GridField(
                'Mitarbeiter',
                'Mitarbeiter',
                $this->owner->Mitarbeiter(),
                GridFieldConfig_RelationEditor::create()
             );

    Can anybody help?

  • dacar
    Avatar
    Community Member
    168 Posts

    Re: customsiteconfig and gridfield Link to this post

    Hi, got it working by myself:

       $mitarbeiterFieldConfig = GridFieldConfig::create()->addComponents(
              new GridFieldToolbarHeader(),
              new GridFieldAddNewButton('toolbar-header-right'),
              new GridFieldSortableHeader(),
              new GridFieldDataColumns(),
              new GridFieldPaginator(10),
              new GridFieldEditButton(),
              new GridFieldDeleteAction(),
              new GridFieldDetailForm(),
              new GridFieldSortableRows('SortOrder')
             );
             $mitarbeiterField = new GridField('Mitarbeiter', 'Mitarbeiterliste', new DataList('Mitarbeiter'), $mitarbeiterFieldConfig);
             $fields->addFieldToTab('Root.Mitarbeiter', $mitarbeiterField);

    greetings, carsten.

  • Beau
    Avatar
    Community Member
    5 Posts

    Re: customsiteconfig and gridfield Link to this post

    I have been having the same issue and have tried applying the changes you made with no success.

    Which part of your changes in particular fixed the issue?

    Anyone else have any experience using GridField in a SiteConfig extension?

    426 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.