I have a data object that contains tournament standings.
class Standing extends DataObject
{
static $db = array (
'Place' => 'Text',
'Prize' => 'Text',
'Bowler' => 'Text',
'Series' => 'Text',
'Average' => 'Text',
'Handicap' => 'Text',
'Game1' => 'Text',
'Game2' => 'Text',
'Game3' => 'Text',
'Game4' => 'Text'
);
static $summary_fields = array (
'Place' => 'Place',
'Prize' => 'Prize',
'Bowler' => 'Bowler',
'Series' => 'Series',
'Average' => 'Average',
'Handicap' => 'Handicap',
'Game1' => 'Game1',
'Game2' => 'Game2',
'Game3' => 'Game3',
'Game4' => 'Game4',
'Season' => 'Season'
);
static $belongs_many_many = array(
'Season' => 'SeasonPage'
);
static $searchable_fields = array (
'Season.ID' => array(
'title' => 'Season'
)
);
function getCMSFields()
{
$fields = parent::getCMSFields();
$fields->addFieldToTab("Root.Main", new TextField('Place', 'Place'));
$fields->addFieldToTab("Root.Main", new TextField('Prize', 'Prize'));
$fields->addFieldToTab("Root.Main", new TextField('Bowler', 'Bowler'));
$fields->addFieldToTab("Root.Main", new TextField('Series', 'Series'));
$fields->addFieldToTab("Root.Main", new TextField('Average', 'Average'));
$fields->addFieldToTab("Root.Main", new TextField('Handicap', 'Handicap'));
$fields->addFieldToTab("Root.Main", new TextField('Game1', 'Game1'));
$fields->addFieldToTab("Root.Main", new TextField('Game2', 'Game2'));
$fields->addFieldToTab("Root.Main", new TextField('Game3', 'Game3'));
$fields->addFieldToTab("Root.Main", new TextField('Game4', 'Game4'));
// Season
$Season = DataObject::get('SeasonPage');
$fields->addFieldToTab("Root.Season", new CheckboxsetField('Season', 'Season', $Season));
return $fields;
}
}
It belongs many many to SeasonPage.
class SeasonPage extends Page
{
static $many_many = array(
'Standings' => 'Standing'
);
static $allowed_children = array(
'none' => 'none'
);
}
class SeasonPage_Controller extends Page_Controller
{
//Return the list of standings for this season
public function getStandingsList()
{
return $this->Standings(Null, 'Place ASC');
}
}
What I need is to upload a csv file containing each seasons standings. This seems to work fine except that the standings are not relating to a SeasonPage. If I manually relate the standings to a season then export a csv it shows 2012[] in the Season column. But if I try to import a csv with 2012[] in the Season column the standings don't relate to a SeasonPage.
Any help would be greatly appreciated.