This is what I have so far....
<?php
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 $many_many = array(
// 'Events' => 'Event'
//);
public static $belongs_many_many = array(
'Events' => 'Event',
'Results' => 'Result'
);
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',
'Results' => 'Result'
);
public static $many_many = array(
'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'));
$tablefield = new ManyManyComplexTableField(
$this,
'Teams',
'Team',
array(
'Name' => 'Name',
'CarNumber' => 'CarNumber'
),
'getCMSFields_forPopup'
);
$fields->addFieldToTab("Root.Content.Team Manager",$tablefield);
$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();
}
}
<?php
class Result extends Page {
public static $db = array(
'PositionFinished' => 'Int',
'PointedScored' => 'Int',
'isFastestLap' => 'Boolean'
);
static $has_many = array (
);
public static $has_one = array(
'Event' => 'Event',
'Team' => 'Team'
);
function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab("Root.Content.Main", new NumericField('PositionFinished'));
$fields->addFieldToTab("Root.Content.Main", new NumericField('PointedScored'));
$fields->addFieldToTab("Root.Content.Main", new CheckboxField('isFastestLap'));
$fields->removeFieldFromTab('Root.Content.Main', 'MenuTitle');
return $fields;
}
}
class Result_Controller extends Page_Controller {
public static $allowed_actions = array (
);
public function init() {
parent::init();
}
}
So I need a function in Event.php to full in entered teams and give them a "Result"...
Any help would be absolutely fantastic :)