[SOLVED] Dynamically set replyToAddress in Email Finisher


(Jakob NIMIUS) #1

Hello everybody. I am currently having an issue with email forms that we create in the Neos backend using the form builder. I would like to automatically set the ReplyTo email address to whatever email the frontend user types into the email field.

For this I need to find that value and use it in the EmailFinisher.fusion:

prototype(Neos.Form.Builder:EmailFinisher.Definition).options {
    senderName = 'Client Name'
    senderAddress = 'info@domain.tld'
    templatePathAndFilename = 'resource://My.Theme/Private/Templates/Form/Finishers/Email.html'
}

Here I am at a loss how to get the value from the corresponding field in my fusion script. I guess it would look somewhat like this:

replyToAddress = ${form.formState.formValues.email}

if I set the identifier for that field to email. However I have not found a way to re-use the field values in the fusion script.

Can anybody help here?


(Bastian Waidelich) #2

The EmailFinisher replaces all Strings “{<identifier>}” for all options with the corresponding form element value.

Give the corresponding field an identifier:

And then refer to it in the finisher options:
image

PS: For the email body it is slightly different, because that is rendered via Fluid and makes the form values available as “{formValues.<identifier>}” variables.

If you want to pre-define the replyToAddress in the Finisher definition you can do this:

prototype(Neos.Form.Builder:EmailFinisher.Definition).options {
    replyToAddress = '{email}'
}

But if you build the form in the Neos Backend you have to make sure that this option is not overridden by the corresponding finisher node, i.e. by removing the property from the node type definition:

'Neos.Form.Builder:EmailFinisher':
  properties:
    'replyToAddress': ~

HTH


(Jakob NIMIUS) #3

Thank you again! Using the identifier in curly braces is the key.