Advertisement
Guest User

Untitled

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