Hi
I have a page type "Team" which consists of a team name. I also have an "Event" page type. Within the event page type I want to list multiple teams. So in a new tab in the event window I want to list all the teams I have in the database and me able to select (by a checkbox) multiple teams that are attending this event.
I think I could use HasManyComplexTableField? I also know I need a look up table between then event and the team... here is the code so far...
class Team extends Page {
public static $db = array(
'Name' => 'Text',
'CarNumber' => 'Text',
"Class" => "Enum('Petrol, Diesel', 'Diesel')",
'ContactTelephone' => 'Text',
'ContactEmail' => 'Text',
'CarLocation' => 'Text'
);
static $has_many = array (
'ImageResources' =>'ImageResource',
'Drivers' => 'Driver'
);
public static $has_one = array(
'ProfilePicture' => 'Image'
);
function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab("Root.Content.Main", new TextField('Name'));
$fields->addFieldToTab("Root.Content.Main", new TextField('CarNumber'));
$fields->addFieldToTab("Root.Content.Main", new TextField('ContactTelephone'));
$fields->addFieldToTab("Root.Content.Main", new TextField('ContactEmail'));
$fields->addFieldToTab("Root.Content.Main", new TextField('CarLocation'));
$fields->addFieldToTab("Root.Content.Main", new ImageField('ProfilePicture'));
$fields->addFieldToTab("Root.Content.Main", new DropdownField('Class', 'Class', singleton('Team')->dbObject('Class')->enumValues()));
$managerimages = new ImageDataObjectManager(
$this, // Controller
'Images', // Source name
'ImageResource', // Source class
'Attachment', // File name on DataObject
array(
'Title' => 'Title'
), // Headings
'getCMSFields_forPopup' // Detail fields
// Filter clause
// Sort clause
// Join clause
);
$fields->addFieldToTab("Root.Content.Image Gallery",$managerimages);
return $fields;
}
}
class Team_Controller extends Page_Controller {
public static $allowed_actions = array (
);
public function init() {
parent::init();
}
}
<?php
class Event extends Page {
public static $db = array(
'Date' => 'Date',
'Time' => 'Time',
'isNextRace' => 'Boolean'
);
static $has_one = array (
//'Track' => 'Track'
);
static $has_many = array (
'ImageResources' =>'ImageResource',
'Teams' => 'Team',
);
function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab("Root.Content.Main", new DatePickerField('Date'));
$fields->addFieldToTab("Root.Content.Main", new TimeField('Time'));
$fields->addFieldToTab("Root.Content.Main", new CheckboxField('isNextRace'));
$managerimages = new ImageDataObjectManager(
$this, // Controller
'Images', // Source name
'ImageResource', // Source class
'Attachment', // File name on DataObject
array(
'Title' => 'Title'
), // Headings
'getCMSFields_forPopup' // Detail fields
// Filter clause
// Sort clause
// Join clause
);
$fields->addFieldToTab("Root.Content.Image Gallery",$managerimages);
return $fields;
}
}
class Event_Controller extends Page_Controller {
public static $allowed_actions = array (
);
public function init() {
parent::init();
}
}
Now the structure of the teams is simply put into a holding container and then adding each page under that...
- Team holder
-- Team 1
-- Team 2
I then have...
- Season
-- 2011
-----Event 1
-----Event 2
So that I can use teams across seasons...
In summary:
how do I get a list of teams into an event and then select which teams are attending that event?
Thanks for any help!