Skip to content

Instantly share code, notes, and snippets.

@maxime-rainville
Created October 31, 2022 20:58
Show Gist options
  • Save maxime-rainville/f80425b399247717602689570cbe430f to your computer and use it in GitHub Desktop.
Save maxime-rainville/f80425b399247717602689570cbe430f to your computer and use it in GitHub Desktop.
Example to setup multiple action on a form
<?php
namespace {
use SilverStripe\CMS\Controllers\ContentController;
use SilverStripe\Forms\FieldList;
use SilverStripe\Forms\Form;
use SilverStripe\Forms\FormAction;
use SilverStripe\Forms\TextField;
class PageController extends ContentController
{
private static $allowed_actions = [
'Form',
];
public function Form()
{
return Form::create(
$this,
'Form',
FieldList::create(
TextField::create('Test')
),
FieldList::create(
FormAction::create('save', 'Save'),
FormAction::create('submit', 'Submit'),
FormAction::create('cancel', 'Cancel'),
)
);
}
public function save($data, $form)
{
die('Do Save');
}
public function submit($data, $form)
{
die('Do submit');
}
public function cancel($data, $form)
{
die('Do cancel');
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment