0

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?

Leon
  • 15
  • 3

2 Answers2

1

Okay, so I finally found a simple solution to my original problem, which does not even need a custom EmailFinisher.

All form elements have a property called identifier, which can be used as a placeholder. just put that into the reply-to property of the emailfinisher from the neos backend (in the inspector) and it is automagically used as the content of reply-to.

Like so: {identifier}. So in my case I chose email as the ID of my input field for the email address in the form, so I needed to put {email} into the reply-to property.

Leon
  • 15
  • 3
0

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?

  • You're right, it needs to be in the `default` preset. I copied that configuration from another project and never seemed to have understood what I was doing here ;) – Leon Nov 10 '21 at 12:49