Advertisement
Guest User

Untitled

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