Jump to:

3377 Posts in 1001 Topics by 714 members

Data Model Questions

SilverStripe Forums » Data Model Questions » Permissions and canCreate()

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

Page: 1
Go to End
Author Topic: 921 Views
  • neros3
    Avatar
    Community Member
    51 Posts

    Permissions and canCreate() Link to this post

    Hi

    I have a class that extends Page.
    I have implemented the canCreate($member = null) function on it.
    On another page that holds a custom form to create a new page I was hoping that the canCreate function was called on write or perhaps on the instantiation (new). But the function is never called.

    Is the canCreate not called automatically? Perhaps not working on Page? I'm confused.

    MyPage.php

    class MyPage extends Page {
    static $db = array(
    );
    static $has_one = array(
    );

    public function canCreate($member = null){

    echo "<h1>lala</h1>";
    return false;

    }
    }

    MyForm.php

    public function canCreate($member = null){

    $mypage = new MyPage();
    $mypage->Title = "my page";
    $mypage->write(); // I would expect something to happen here, but the page is just created like any other page.

    }

  • neros3
    Avatar
    Community Member
    51 Posts

    Re: Permissions and canCreate() Link to this post

    Hi folks
    So far I've come to the conclusion that the canCreate function is only automatically called from the CMS. Anyone wants to support this statement?
    Thanks!

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