Formit with dynamic autoresponder?

Hi, I have a form with a select for some subjects. Each subject creates a different email recipient. I tried the emailSelectTo and emailSelectField properties but they don’t work. So I used a snippet from this thread: Trouble with Formit &emailTo and Dropdown Selection - #3 by carlo_13 – very helpful!

Now my problem is: I need an autoresponder only for two subjects (not for all). I tried an output modifier with the select field in the hooks property. Doesn’t work. Tried the FormItAutoResponder in the &hooks and the output modifier for setting the fiar properties. Now I got everytime a standard respond mail.

Is there a way to set the FormItAutoResponder dynamically?
Thank you very much for the helpful tips!

That’s the select part of the form:

<select id="betreff" name="betreff" value="[[!+fi.betreff]]">
	<option value="" disabled selected hidden>bitte auswählen:</option>
	<option value="Allgemeine Anfrage" [[!+fi.betreff:FormItIsSelected=`Allgemeine Anfrage`]]>Allgemeine Anfrage</option>
	<option value="Kontoänderung" [[!+fi.betreff:FormItIsSelected=`Kontoänderung`]]>Kontoänderung</option>
	<option value="Adressänderung" [[!+fi.betreff:FormItIsSelected=`Adressänderung`]]>Adressänderung</option>
	<option value="Kündigung" [[!+fi.betreff:FormItIsSelected=`Kündigung`]]>Kündigung der Mitgliedschaft</option>
</select>

I only need the Autoresponder for “Kontoänderung” and “Adressänderung”. firaTpl and fiarSubject are in the Formit call:

  &fiarTpl = `form-contact-auto`
  &fiarSubject = `Ihre Information zur [[+betreff]]`

The &hooks:

&hooks=`getRecipient,email,redirect`

getRecipient is the snippet from the thread linked above.

You probably have to write a custom hook snippet.

You could either send the email yourself in the custom hook (similar to the way it’s described here in the docs) or you could try to (selectively) call the original Autoresponder hook from your custom hook. Something like this:

...
$autoresponder = new Sterc\FormIt\Hook\Autoresponder($hook, $hook->config);
$success = $autoresponder->process($fields);
...

Great, that works! Many thanks.

That’s the custom hook:

<?php
// Get the value of the subject from the submitted form
$subject = $hook->getValue('betreff');

// Set the hook based on the dropdown value
if ($subject == 'Kontoänderung' || $subject == 'Adressänderung') {
    // Dynamically add FormItAutoResponder to the hooks list
    $autoresponder = new Sterc\FormIt\Hook\Autoresponder($hook, $hook->config);
	$success = $autoresponder->process($fields);
}

// Set the hook
return true;