Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Team.php
- class Team extends Page {
- private static $has_one = array(
- 'TeamTypes' => 'TeamType'
- );
- // Additional Tab to add additional Team Types
- $fields->addFieldToTab('Root.TeamTypes', GridField::create(
- 'TeamTypesID',
- 'Team categories',
- $this->TeamTypes(),
- GridFieldConfig_RecordEditor::create()
- ));
- // Dropdown options
- $field = DropdownField::create(
- 'TeamTypesID', //Name of has one relationship
- 'Team Category', //Title or Label
- TeamType::get()->map('ID', 'Title')) //Source
- ->setEmptyString('(Select one)'); //Add an empty string
- $fields->addFieldToTab('Root.Main', $field, 'Content');
- $fields->addFieldToTab('Root.Main', TextField::create('Website'), 'Content');
- return $fields;
- }
- }
- //TeamType
- class TeamType extends DataObject {
- private static $db = array(
- 'Title' => 'Varchar'
- );
- private static $has_many = array(
- 'Teams' => 'Team'
- );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement