neoscms

Neos.Form.Builder: Setting the reply-to address to an email entered by the user filling in the contact form


I'm trying to set the reply-to email address of the email sent by an EmailFinisher to an email entered by the visitor of the website who fills out the contact form.

I tried the following, working through the README of https://github.com/neos/form-builder#custom-form-elements, adapting it to my needs.

A php class for the new finisher looks like this (first draft):

<?php

namespace Vendor\Site\Form\Finisher;

use Neos\Flow\Annotations as Flow;
use Neos\Form\Exception\FinisherException;
use Neos\Form\Finishers\EmailFinisher;

class EmailWithDynamicReplytoFinisher extends EmailFinisher
{
    /**
     * Executes this finisher
     * Sends a mail with the reply-to address set to the address supplied by the customer who filled the form
     *
     * @return void
     * @throws FinisherException
     * @see AbstractFinisher::execute()
     *
     */
    protected function executeInternal()
    {
        $this->options['replyToAddress'] = 'test@foo.bar';

        parent::executeInternal();
    }
}

Then I overrode the EmailFinisher of the original package like so:

'Neos.Form.Builder:EmailFinisher':
  options:
    form:
      formElementType: 'Vendor.Site:EmailWithDynamicReplytoFinisher'

The change took effect as the rendering broke. It says: The finisher preset identified by "Vendor.Site:EmailWithDynamicReplytoFinisher" could not be found, or the implementationClassName was not specified.

The same effect happens, if I try overriding it via fusion:

prototype(Neos.Form.Builder:EmailFinisher.Definition) {
    formElementType = 'Vendor.Site:EmailWithDynamicReplytoFinisher'
}

I thought that this configuration would tell Neos where to look for the finisher implementation but it does not seem to make a change at all (note: my package depends on neos/form-builder, so I think loading order should not be a problem here):

Neos:
  Form:
    presets:
      fusion:
        finisherPresets:
          'Vendor.Site:EmailWithDynamicReplytoFinisher':
            implementationClassName: Vendor\Site\Form\Finisher\EmailWithDynamicReplytoFinisher
            options: { }

What am I missing? How to make Neos find the implementation and actually use it?


Solution

  • The finisher preset identified by "Oekokiste.Core:EmailWithDynamicReplytoFinisher" could not be found

    You defined this finisher in the fusion preset. Do you use that to render the form, too?