Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Position of the submit button


Go to End


2 Posts   405 Views

Avatar
Bagzli

Community Member, 71 Posts

18 January 2015 at 8:09am

Edited: 18/01/2015 8:14am

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.

Attached Files
Avatar
martimiz

Forum Moderator, 1391 Posts

20 January 2015 at 7:31am

Edited: 20/01/2015 7:31am

By default SilverStripe will always create forms with fields first and actions last. I'd probably first try to accomplish this using css. You could also create a custom Form template...