Hello,
I have a php class as follows:
<?php
class ADLScoreManager extends Page {
}
class ADLScoreManager_Controller extends Page_Controller {
private static $allowed_actions = array('GameResultForm');
public function GameResultForm() {
$gameDate = new DateField('GameDate');
$gameDate->setConfig('showcalendar', true);
$gameDate->setConfig('dateformat', 'dd/MM/YYYY');
$fields = new FieldList (
$gameDate,
new OptionsetField(
$name = "WinningTeam",
$title = "Who won?",
$source = array(
"1" => "Team 1",
"2" => "Team 2"
),
$value = "1"
),
new OptionsetField(
$name = "TeamOneMVP",
$title = "Who is the MVP for Team 1?",
$source = array(
"1" => "Player A",
"2" => "Player B",
"3" => "Player C",
"4" => "Player D",
"5" => "Player E"
),
$value = "1"
),
new TextField('PlayerA'),
new TextField('PlayerB'),
new TextField('PlayerC'),
new TextField('PlayerD'),
new TextField('PlayerE'),
new OptionsetField(
$name = "TeamTwoMVP",
$title = "Who is the MVP for Team 2?",
$source = array(
"1" => "Player F",
"2" => "Player G",
"3" => "Player H",
"4" => "Player I",
"5" => "Player J"
),
$value = "1"
),
new TextField('PlayerF'),
new TextField('PlayerG'),
new TextField('PlayerH'),
new TextField('PlayerI'),
new TextField('PlayerJ')
);
$actions = new FieldList(
new FormAction('SaveNewGame', 'Save New Group')
);
return new Form($this, '', $fields, $actions);
}
public function SaveNewGame($data, $form){
$adlPlayerOne = ADLPlayer::create();
$adlPlayerOne->SummonerTag = 'ThisIsATest';
$adlPlayerOne->write();
}
public function GetPlayers(){
$holder = ADLPlayer::get()->First();
return $holder;
}
}
I also have a data model as follows:
<?php
class ADLPlayer extends DataModel {
private static $db = array(
'SummonerTag' => 'Varchar',
'Rating' => 'Decimal',
'GamesWon' => 'Int',
'GamesLost' => 'Int',
'LastPlayed' => 'Date'
);
}
class ADLPlayer_Controller extends Page_Controller {
}
And a .ss page as follows:
<div id="BrowserPoll">
<h2>Browser Poll</h2>
$GameResultForm
1
<% loop $GetPlayers() %>
$SummonerTag
<% end_loop %>
2
</div>
Right now there is no validation, because I am just testing this. I am trying to click the submit button, a class for ADLPlayer will be created and then summoner name will be written to that class. Next time I visit the same page, I will have all ADLPlayers listed below. However this is not working and I cannot figure out why. Any help is most appreciated.
Edit:
I have also looked in phpMyAdmin and could not find my ADL tables anywhere. I did run /dev/build and even ?flush=1 on the page.