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

customsiteconfig and gridfield


Go to End


3 Posts   2099 Views

Avatar
dacar

Community Member, 173 Posts

10 February 2013 at 1:22am

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

Community Member, 173 Posts

10 February 2013 at 3:11am

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

Community Member, 5 Posts

18 February 2013 at 12:35pm

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?