Hey there,
I am having some problems saving content on a $has_many link. I have 2 classes Team (extends Page) and Fixture (extends DataObject). When i try to save the Team page, I get an "Error saving content" error. There is no message show or in the error logs. I am a bit stumped with this.
Could anyone help?
Team.php
<?php
class Team extends Page {
static $db = array(
'TeamDivision' => 'Text',
'TeamManager' => 'Text',
'TeamLeague' => 'Text'
);
static $has_many = array(
'Fixtures' => 'Fixture'
);
function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab( 'Root.Content.Main', new TextField('TeamManager', 'Team Manager'), 'Content');
$fields->addFieldToTab( 'Root.Content.Main', new TextField('TeamDivision', 'Team Division'), 'TeamManager');
$fields->addFieldToTab( 'Root.Content.Main', new TextField('TeamLeague', 'Team League'), 'TeamDivision');
$tablefield = new HasManyComplexTableField(
$this,
'Fixutres',
'Fixture',
array(
'FixtureDate' => 'Fixutre Date',
'Opposition' => 'Opposition',
'HomeOrAway' => 'Home or Away',
'Location' => 'Location',
'Postcode' => 'Postcode',
'IsLeague' => 'League match'
),
'getCMSFields_forPopup'
);
$tablefield->setAddTitle( 'A Fixture' );
$fields->addFieldToTab( 'Root.Content.Fixtures', $tablefield );
return $fields;
}
}
class Team_Controller extends Page_Controller {
function init() {
parent::init();
}
}
?>
and Fixture.php
<?php
class Fixture extends DataObject {
static $db = array(
'FixtureDate' => 'Date',
'Opposition' => 'Text',
'HomeOrAway' => 'Text',
'Location' => 'HTMLText',
'Postcode' => 'Text',
'IsLeague' => 'Text'
);
static $has_one = array(
'MyTeam' => 'Team'
);
function getCMSFields_forPopup() {
$fields = new FieldSet();
$fields->push( new CalendarDateField( 'FixtureDate', 'Fixture Date' ) );
$fields->push( new TextField( 'Opposition' ) );
$fields->push( new DropdownField(
'HomeOrAway',
'Home Or Away',
array(
'HOME' => 'Home',
'AWAY' => 'Away'
)));
$fields->push( new DropdownField(
'IsLeague',
'League Match?',
array(
'NO' => 'No',
'YES' => 'Yes'
)));
$fields->push( new TextAreaField( 'Location', 'Location of Match' ) );
$fields->push( new TextField( 'Postcode' ) );
return $fields;
}
function forTemplate() {
$template = 'FixtureDetails';
return $this->renderWith( $template );
}
}
?>