Actions
Introduction
Form actions
determine what your form does when submitted. Most actions assume the form saves and then does something else like redirect to a table of entries or a new form to continue editing the entry.
Action Definition
Below is a list of all action specific definition properties. Actions extend buttons
so you may want to refer to button documentation for a complete set of options for buttons.
Key | Required | Type | Default | Description |
---|---|---|---|---|
slug | true | string | The definition key. | The action becomes the submit button's name. |
redirect | false | string | Back to the form. | The action redirect URL. |
handler | false | string | null | A callable class string. This is useful when you want to include additional logic when a form is submitted using an action. |
Registered Actions
There are a number of actions already registered in the \Anomaly\Streams\Platform\Ui\Form\Component\Action\ActionRegistry
class. To use any of these actions simply include their registered string slug.
protected $actions = [
'save',
];
You can override actions by including more information in your definition.
protected $actions = [
'save' => [
'redirect' => 'admin/products/view/{entry.id}',
],
];
Defining Actions
Define properties within the builder using the actions
property.
protected $actions = [
'save',
];
You can also set actions dynamically.
$builder->setActions(array $actions);
$builder->addAction($slug, array $definition = []);