How to implement custom form actions with Neos.Fusion.Form?


I - successfully - implemented a contact form based on Neos.Fusion.Form - SingleStepProcess. The standard “message” action and “log” action are working fine.

Now I’m trying to implement a custom action in PHP but fail at the very basics.
I took the class MessageAction from the Custom Form Actions docs and renamed it to class ExchangeWebServicesMailAction. But I don’t know / didn’t find the conventions for the class filename and path and if the class has to be configured somewhere to be known.
I placed it in DistributionPackages/MYCOMPANY.Site/Classes/Action/ExchangeWebServicesMailAction.php

Currently I get

An exception was thrown while Neos tried to render your page
The action handler “MYCOMPANY.Site:ExchangeWebServicesMail” was could not be resolved!

Where do I have to place the class file? Do I have to configure it somewhere? Does an action class need a fusion file?

Some help and enlightenment would be very appreciated :slight_smile:

Thx, Björn

Hi Björn

I recently implemented this for the package Wegmeister.DatabaseStorage and also had some troubles finding out how that works.

You can use the fully-qualified class name, see example.

BTW, it is explained in the official documentation.

Hi Lorenz,

thanks for the hint. That was one necessary building block. After several days of tedious trial and error :sweat_smile: I found two further prerequisites: configure the classes path in the composer.json (which you also have in your project) and refresh the composer and flow system.

So alltogether to get the Custom (Fusion) Form Actions up and running I had to…

  1. alter the action type to the path notation
    action {
            type = 'MYCOMPANY\\Site\\Action\\ExchangeWebServicesMailAction'
            options.message = afx`<h1>Thank you {data.firstName} {data.lastName}</h1>`
  1. since this is my first php class in my project: add composer autoload for the Classes subpath in DistributionPackages\MYCOMPANY.Site\composer.json
    "autoload": {
        "psr-4": {
            "MYCOMPANY\\Site\\": "Classes/"
    "autoload-dev": {
        "psr-4": {
            "MYCOMPANY\\Site\\": "Classes/"

Correspondingly my class ExchangeWebServicesMailAction extends AbstractAction is in the file DistributionPackages\MYCOMPANY.Site\Classes\Action\ExchangeWebServicesMailAction.php .

  1. refresh composer and flow by
composer dump-autoload
composer install
./flow neos.flow:cache:flush
sudo service apache2 restart

Not sure which of these are unavoidable but without them my changes did not become effective. I think dump-autoload and cache:flush are a must in this case.

The autoload part of composer is crucial, for the autoloader to know, what files to load for the application :+1:

The autoload-dev shoulds only be your Tests classes - see here, how the form package configures it

True, that composer dump-autoload and/or ./flow neos.flow:package:rescan has been the parts, that loaded your package files into the application, and make your action work :partying_face:

Great work @Bjorn - hope you will have fun :smiley: