mplodowski / formbuilder-plugin-public

https://octobercms.com/plugin/renatio-formbuilder
https://octobercms.com/plugin/renatio-formbuilder
2 stars 0 forks source link

Error Sending Form After Updating to 2.1.0 #2

Closed kombimedia closed 2 years ago

kombimedia commented 2 years ago

Describe the bug I have updated to the latest version of the plugin 2.1.0 and run the database patch. Now when a form is submitted an alert window pops up with a 'something went wrong' message.

To Reproduce Steps to reproduce the behavior:

  1. Go to a form on the front end
  2. Complete the form fields
  3. Click submit
  4. Alert message pops up with 'something went wrong' alert message

Expected behavior I expected the form to submit

Screenshots Screen Shot 2021-11-22 at 15 24 29

Screen Shot 2021-11-22 at 15 40 38

October version 2.1.21

Plugin version 2.1.0

Additional Details I am extending the FormBuilder plugin to dynamically set the recipient name and email before the message is sent.

     public function boot() {
      \Event::listen('formBuilder.beforeSendMessage', function ($form, $data) {
        $form->to_email = $data['recipient_email'];
        $form->to_name = $data['recipient_name'];

      });

Hope you can help.

Cy

mplodowski commented 2 years ago

Please go to the backend Settings -> Event Log. There should be error record. Copy and paste error message and stack trace.

In new version to_email and to_name field are replaced with repeater recipients field.

I think you can remove this boot method and use Autoresponder feature, where you can specify which fields to use and even the mail template.

mplodowski commented 2 years ago

If you want to use boot method to change recipients than this is the code to use now:

\Event::listen('formBuilder.beforeSendMessage', function ($form, $data) {
    $form->recipients = [
        [
            'email' => $data['recipient_email'],
            'recipient_name' => $data['recipient_name'],
        ]
    ];
});
kombimedia commented 2 years ago

Hi @mplodowski,

Thanks for your speedy response.

There was no event logged for this error.

Thanks also for the updated boot method snippet. Because the email recipient will always need to be dynamically injected I have gone for this method to override the default recipient, preventing two emails being sent.

Cheers

mplodowski commented 2 years ago

Without seeing error message there is very limited way to help you.

The only way to see this error is to enable APP_DEBUG = true in .env file.

You can also run: composer update in project root.

The last resort should be reinstalling plugin, but can cause data loss.

kombimedia commented 2 years ago

@mplodowski,

Sorry, I wasn't clear. I'm not receiving the error anymore. I have updated my boot method to the one you provided, and removed un-required recipient repeaters that had been generated after upgrading to 2.1.0. I think the error i was receiving was due to a 'new recipient' not having an email address defined.

Thanks

mplodowski commented 2 years ago

Super! I am glad it works now.