Jump to content

FormBuilder: Change SuccessMessage by a Hook


Recommended Posts


How can I put out the value from a formfield in the Sucess Message in FormBuilder by a Hook?

For example:

  • The value from the formfield "message" = "Vielen Dank". The SucessMessage should be "Vielen Dank".
  • The value from the formfield "message" = "Thank you". The SucessMessage should be "Thank you".

I hope you understand my request ;-).

Thank you in advance!

Link to comment
Share on other sites

This is what I've saved from FB subforum


In site/ready.php I add this code...

$forms->addHookAfter('FormBuilderProcessor::formSubmitSuccess', function($event) {
    $form = $event->object;
    if ($form->formName == 'YOUR-FORM-NAME-HERE' && $form->isSubmitted()) {
        $values = $form->getValues();
        array_walk($values, function(&$i){ $i = htmlentities($i, ENT_QUOTES, 'UTF-8', false); });
        $form->successMessage = wirePopulateStringTags($form->successMessage, $values);

... changing 'YOUR-FORM-NAME-HERE' for the actual name of your form.

I can now include submitted values in my success messages. Like this;

Thank you, {name}. A confirmation email has been sent to {email}.

  • Thanks 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...