Jump to:

23453 Posts in 18902 Topics by 2877 members

General Questions

SilverStripe Forums » General Questions » Allowing Content Authors to edit dataobject in 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: 891 Views
  • James Bolitho
    Avatar
    Community Member
    33 Posts

    Allowing Content Authors to edit dataobject in Gridfield Link to this post

    Hi,

    I am having a bit of trouble working out how to allow Content Authors to create, edit, publish and delete records through the Gridfield.

    In Silverstripe 2.4 I just used to add the following code to the dataobject that was being managed through a complex table field for example but this doesn't seem to work for the Gridfield in 3.0:

    function canEdit() { return true; }
    function canDelete() { return true; }
    function canCreate() { return true; }
    function canPublish() { return true; }

    I am sure I am missing something simple so would be grateful if anyone could point me in the right direction.

    Cheers,

    Jim

    [bold]Edit[/bold]

    I was right I just missed out something really obvious. Just needed to add canView. This is what I ended up using for information:

    function canEdit($member = null)
    {
    return true;
    }
    function canDelete($member = null)
    {
    return true;
    }
    function canCreate($member = null)
    {
    return true;
    }
    function canPublish($member = null)
    {
    return true;
    }
    function canView($member = null)
    {
    return true;
    }

  • Chris Dangerfield
    Avatar
    Community Member
    8 Posts

    Re: Allowing Content Authors to edit dataobject in Gridfield Link to this post

    Thanks for this James - really helpful!

    And, just so that others don't make the same mistake - don't include the canPublish() permission, as that seems to be just on SiteTree and when I included this it mucked things up for me.

  • kinglozzer
    Avatar
    Community Member
    139 Posts

    Re: Allowing Content Authors to edit dataobject in Gridfield Link to this post

    Just for reference, the way I usually do this is:

    /**
    * @return boolean
    */
    public function canView($member = null) {
       return Permission::check('CMS_ACCESS_CMSMain');
    }

    /**
    * @return boolean
    */
    public function canCreate($member = null) {
       return Permission::check('CMS_ACCESS_CMSMain');
    }

    /**
    * @return boolean
    */
    public function canEdit($member=null) {
       return Permission::check('CMS_ACCESS_CMSMain');
    }

    /**
    * @return boolean
    */
    public function canDelete($member = null) {
       return Permission::check('CMS_ACCESS_CMSMain');
    }

  • cmc
    Avatar
    Community Member
    23 Posts

    Re: Allowing Content Authors to edit dataobject in Gridfield Link to this post

    Thanks for this answer and thanks for using a descriptive subject line. After searching Google and Silvertripe.org with variations including "content editors" and "dataextension" I was about to start a separate topic. Fortunately I saw this in the topic list first.

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