Created
November 21, 2012 11:22
-
-
Save svandragt/4124420 to your computer and use it in GitHub Desktop.
Debug shows steps, but gridfield doesn't if author is not admin.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Debug shows steps, but gridfield doesn't if author is not admin. I can open the step if I know the url though, but the gridfield says 'no items found'. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class HowtoPage extends DocumentPage { | |
public static $has_many = array( | |
'Steps' => 'Step', | |
); | |
public function getCMSFields() { | |
$fields = parent::getCMSFields(); | |
Debug::show($this->Steps()); // shows steps when exist | |
$gf_config = GridFieldConfig::create()->addComponents( | |
new GridFieldToolbarHeader(), | |
new GridFieldAddNewButton('toolbar-header-right'), | |
new GridFieldSortableHeader(), | |
new GridFieldDataColumns(), | |
new GridFieldEditButton(), | |
new GridFieldDeleteAction(), | |
new GridFieldDetailForm() | |
); | |
$gridfield = new GridField("Steps", "Steps:", $this->Steps()->sort(array('SortOrder' => 'asc', 'ID'=>'asc')), $gf_config); | |
$fields->insertAfter($gridfield, "Content"); // shows gridfield but with 'no items found' | |
return $fields; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Solution: add the following methods to the Step.php DataObject:
public function canView($member = null) {
return $this->HowtoPage()->canView($member);
}