Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //TeamType.php
- class TeamType extends DataObject {
- private static $db = array(
- 'Title' => 'Varchar'
- );
- // private static $has_one = array (
- // 'TeamTypes' => 'Team'
- // );
- private static $has_many = array(
- 'Teams' => 'Team'
- );
- }
- class TeamType_Controller extends Page_Controller {
- }
- ?>
- <?php
- //Team.php
- class Team extends Page {
- private static $db = array(
- 'Title' => 'Text',
- 'Logo' => 'Text',
- 'Website' => 'Text',
- 'Order' => 'Int'
- );
- private static $has_one = array(
- 'TeamTypes' => 'TeamType'
- );
- function getCMSFields() {
- $fields = parent::getCMSFields();
- $field = DropdownField::create(
- 'TeamTypeDropdown', // arbitrary Name
- '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;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement