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.

General Questions

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

customsiteconfig and gridfield


Reply

3 Posts   563 Views

Avatar
dacar

10 February 2013 at 1:22am Community Member, 168 Posts

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?

Avatar
dacar

10 February 2013 at 3:11am Community Member, 168 Posts

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.

Avatar
Beau

18 February 2013 at 12:35pm Community Member, 5 Posts

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?