Hello,
I'm trying to create a form and I want to have the submit button be between the elements and I'm not quite sure how to accomplish that. I'm attaching a screnshot to show you the wireframe. How can alter order of elements on the form with silverstripe so that the Add Group button comes after the date and before everything else.
Here is what I tried:
public function GameResultForm() {
$gameDate = new DateField('GameDate');
$gameDate->setConfig('showcalendar', true);
$gameDate->setConfig('dateformat', 'dd/MM/YYYY');
$fields = new FieldList (
$gameDate,
new FormAction('doBrowserPoll', 'Add Group'),
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('doBrowserPoll', 'Add Group')
);
return new Form($this, 'GameResultForm', $fields, $actions);
The button is added after the date and it works if I click on it, however the issue is that there are 2 buttons on the page due to $actions array at the bottom. If I remove the $actions code then the page loads white, it won't work.