Created
October 31, 2022 20:58
-
-
Save maxime-rainville/f80425b399247717602689570cbe430f to your computer and use it in GitHub Desktop.
Example to setup multiple action on a form
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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