Advertisement
Guest User

Untitled

a guest
Apr 14th, 2015
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. //Team.php
  2. class Team extends Page {
  3.  
  4. private static $has_one = array(
  5. 'TeamTypes' => 'TeamType'
  6. );
  7.  
  8.  
  9. // Additional Tab to add additional Team Types
  10. $fields->addFieldToTab('Root.TeamTypes', GridField::create(
  11. 'TeamTypesID',
  12. 'Team categories',
  13. $this->TeamTypes(),
  14. GridFieldConfig_RecordEditor::create()
  15. ));
  16.  
  17. // Dropdown options
  18. $field = DropdownField::create(
  19. 'TeamTypesID', //Name of has one relationship
  20. 'Team Category', //Title or Label
  21. TeamType::get()->map('ID', 'Title')) //Source
  22. ->setEmptyString('(Select one)'); //Add an empty string
  23.  
  24. $fields->addFieldToTab('Root.Main', $field, 'Content');
  25. $fields->addFieldToTab('Root.Main', TextField::create('Website'), 'Content');
  26.  
  27. return $fields;
  28. }
  29. }
  30.  
  31. //TeamType
  32. class TeamType extends DataObject {
  33. private static $db = array(
  34. 'Title' => 'Varchar'
  35. );
  36.  
  37. private static $has_many = array(
  38. 'Teams' => 'Team'
  39. );
  40.  
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement