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.

Customising the CMS /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

GridFieldDetailForm_ItemRequest data only available to admin users?


Go to End


2 Posts   1133 Views

Avatar
rob087

Community Member, 1 Post

6 December 2016 at 1:00am

Hi there,

I have a GridFieldDetailForm_ItemRequest class I created by essentially following this post: https://www.silverstripe.org/community/forums/customising-the-cms/show/29132

However, the data object instances associated to this class only seem to be returned when logged in as an admin user. Any other user type that doesn't have the 'Full administrator privileges' permission can't seem to see any of that data.

They can see the ModelAdmin link in the main left hand toolbar, along with all the summary fields associated to the DataObject - just none of the data itself.

Has anyone else seen this before? Is it possible to allow any users to see this data?

Happy to provide code samples of more information as needed. Any and all help is greatly appreciated - thanks for reading.

Avatar
blackduck

Community Member, 13 Posts

6 December 2016 at 4:42pm

Edited: 06/12/2016 8:05pm

You need to add permissions into your dataobject.
I tend to use something like the following to have rights based on the containing page.

class myClass extends DataObject {
	private static $db = array(
		...
	);

	private static $has_one = array(
		'Parent'	=> 'containingClass',	//Link back to parent page
	);

// Permissions: Set permissions based on parent. Allows non-admins to edit this dataobject.
	function canView($member=NULL) { 
		return $this->Parent()->canView($member);
	}
	function canEdit($member=NULL) {
		return $this->Parent()->canEdit($member);
	}
	function canCreate($member=NULL) {
		return true;
	}
//Often don't give delete rights to non-admins
	/*function canDelete($member=NULL) {
		return $this->Parent()->canEdit($member);
	}
	*/
}

Just swap the myClass, containgClass and Parent to whatever your using.