-
-
Save hailwood/2ed8cf5dc4297ac791be to your computer and use it in GitHub Desktop.
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 OurPeoplePage extends Page { | |
private static $many_many = array( | |
'Team' => 'TeamMember' | |
); | |
private static $many_many_extraFields=array( | |
'Team'=>array( | |
'SortOrder'=>'Int' | |
) | |
); | |
public function getCMSFields() { | |
$fields = parent::getCMSFields(); | |
$config = new GridFieldConfig_RelationEditor(); | |
$config->addComponent(new GridFieldSortableRows('SortOrder')); | |
$config->addComponent($uploader = new GridFieldBulkUpload()); | |
$uploader->setUfSetup('setFolderName', 'TeamMembers'); | |
$config->addComponent(new GridFieldBulkManager()); | |
$config->addComponent(new GridFieldGalleryTheme('Image')); | |
$config->getComponentByType('GridFieldAddExistingAutocompleter') | |
->setSearchFields(array('Title', 'Position', 'Email')) | |
->setResultsFormat('$Title'); | |
$fields->addFieldToTab('Root.TeamMembers', new GridField('Team Members', null, $this->Team(), $config)); | |
return $fields; | |
} | |
public function Team() { | |
return $this->getManyManyComponents('Team')->sort('SortOrder'); | |
} | |
} | |
<?php | |
class TeamMember extends DataObject { | |
private static $belongs_many_many = [ | |
'OurPeoplePages' => 'OurPeoplePage', | |
'ContactPages' => 'ContactPage', | |
]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment