A custom action is usually defined by extending the \Neos\Fusion\Form\Runtime\Action\AbstractAction with a custom class
and implementing the perform method. Inside of perform the defined options are available via $this->options.
namespace Vendor\Site\Action
use Neos\Fusion\Form\Runtime\Domain\ActionInterface;
use Neos\Flow\Mvc\ActionResponse;
class MessageAction extends AbstractAction
{
/**
* @return ActionResponse|null
*/
public function perform(): ?ActionResponse
{
$response = new ActionResponse();
$response->setContent($this->options['message']);
return $response;
}
}
The action class can afterwards be used in a form-action:
action {
message {
type = 'Vendor.Site:Message'
options.message = afx`<h1>Thank you {data.firstName} {data.lastName}</h1>`
}
}
The type identifier is resolved to a classname like [namespace]\\Action\\[name]Action.
Be aware of the ...Action suffix, for example your custom action class should be named MyCustomAction.
If the created action uses a different namespace you can use the fully classified classname as type as well,
e.g. Vendor\\Site\\Foo\\Bar\\Somewhere\\MyCustomAction.
If you are interested to see how the action is resolved, checkout the Neos\Fusion\Form\Runtime\Domain\ActionResolver.php class.