7938 Posts in 1466 Topics by 943 members
|Go to End|
27 August 2012 at 8:52pm Last edited: 7 September 2012 12:59am
Question changed to be more specific
Firstly I'm using SilverStripe 2.4.7. I am tearing my hair out trying to figure out how to do this and I need to help.
Ok so I have a dataobject and I use a dataobjectmanager on the admin's page to look after all of the dataobjects. I also use dataobjectmanager on other user's pages to look after the dataobjects that only relate to them. So the fields in the dataobject are used in the popups on both types of pages (the admin and the user pages).
I need to add a checkbox to the admin page popup only so that when they create one of these dataobjects they can select multiple users and then the ids are saved in a linked table. I hope I'm being clear.
I have my getCMSFields function in my dataobject (Offer) and getCMSFields in AllOffers with a dataobjectmanager. how to I add the checkbox without adding it to every other page too?
7 September 2012 at 1:59am Last edited: 7 September 2012 1:59am
I'm not sure I entirely follow your question, but if I understand correctly, it is about permissions rather than working with the dataobject-manager or relationships ?
You can check whether the user has Admin-rights , and then based on that add the field to the user-interface.
if(Permission::check('ADMIN')) return true;
Make sure to also secure your dataobject-class (you can override the canCreate() / canDelete() methods). E.g. :
if (Permission::check('ADMIN')) return true;
7 September 2012 at 2:05am Last edited: 7 September 2012 2:10am
Hi Fuzz10, thanks for your quick response.
I apologise for being unclear. I'll try to simplify. Basic users have there own page (which only they have access to) and can create movies (dataobject). The movies they create are only linked to them. The admin can edit all movies or create global ones, through their page, that apply to everyone (hence the linked table). Yes I had tried something like that.
if (! empty($stores))
$checkBox = new CheckboxSetField(
$name = "Stores",
$title = "Select Stores",
$source = $stores
But while this displayed the checkboxes perfectly, it caused a problem with saving in the database. Basically it just didn't save. I was thinking I need a function to populate the linked list but this seems like a bit of a hacky workaround.
I was also old that I should move that to the page rather than the dataobject but I'm not sure how.
|Go to Top|