bolt / boltforms

Bolt 3 Forms extension - Symfony interface and API for Bolt
http://bolt.cm
GNU General Public License v3.0
52 stars 56 forks source link

Feedback/success message is never triggered #257

Open eduardomart opened 6 years ago

eduardomart commented 6 years ago

This used to work in BF 3.x but now the 'Feedback' never gets displayed. The form simply refreshes after a successful submission, no feedback at all.

Workaround:

In boltforms.form.yml add the redirect property under feedback, like so:

feedback:
   success: Message sent!  #<--- this is not working
   redirect:
      target: page/contact?success=true

In my case page/contact is the record that loads my contact form, so in its template I use the following code:

{% if app.request.get('success') == true %}
   <p>Message sent!</p>
{% else %}
   {{ boltforms('contact') }}
{% endif %}

That way the success message is only displayed when triggered by the success redirect.

jadwigo commented 6 years ago

@eduardomart the boltforms templates are changed when going from 3.x to 4.x. One of these changes is that the messages are handled a bit differently.

You probably need to rebuild the form customization templates based on the new boltforms templates.

jadwigo commented 6 years ago

@eduardomart did you get any further with this?

eduardomart commented 6 years ago

I did manage to upgrade to boltforms 3.4 4.x, however the issue remains, the success message is not triggered, the page just gets refreshed

Largo commented 5 years ago

Same here

grafik

Largo commented 5 years ago

EDIT: Nevermind this doesn't work all the time. Only sometimes, even after I changed the template to be almost the same. Also the data array in the email lacks all but one formfield. I'll give up now and roll my formcode.

Would be great if this was clearly documented along with the other things I spent 5 hours on today (for instance "choice: content"):

In your formfile replace: {{ form_start(form, {'attr': {'name': formname}}) }} with {{ form_start(form, form_start_param) }}

pragmaworking commented 5 years ago

@jadwigo, could you please elaborate on how to "rebuild the form customization templates based on the new boltforms templates"?

I am currently on BoltForms v4.2.5, but as mentioned, the page seems to be reloading in place of the feedback showing.

Edit: I tested a few versions of BoltForms, and this seems to be an issue starting at v4.2.4 as it's working in v4.2.3.

jadwigo commented 5 years ago

@jadwigo, could you please elaborate on how to "rebuild the form customization templates based on the new boltforms templates"?

Sure.

If you have created custom templates for an older boltforms you need to start over fresh. So start by copying all templates from the boltforms extension to your theme. Set up the boltforms configuration to use the newly copied templates in your theme. Then recreate the customizations you had for the older version of boltforms to the newly copied templates.

Basically: make a copy of the new templates and do all your customizations again in the new templates.

pragmaworking commented 5 years ago

Thanks.

I ended up rolling back to v4.2.3 for a quick fix, but I'll keep the refreshed custom template approach in mind for the future.

dutty5 commented 5 years ago

@jadwigo @pragmaworking I have the same issue: feedback never shown after success submission. I have checked all the differences in stock files in extensions/vendor/bolt/boltforms/templates/ between v.4.2.3 (last working version as mentioned by @pragmaworking, also working for me) and v.4.2.5 and found the only file and only difference in line 329 of extensions/vendor/bolt/boltforms/templates/form/_form_theme.twig. I transferred that difference into my customized template _form_theme.twig in theme folder (derived originally from v.4.2.3) and still have the same issue. Nothing changed.

So I believe minor templates change as suggested by @jadwigo is not the root cause.

[edit] Reverting back to 4.2.3, it looks the only solution right now

COOLak commented 5 years ago

I confirm this. On v4.2.6 the bug is still present: no feedback after successfull submission.

https://github.com/bolt/boltforms/compare/v4.2.3...v4.2.6 - here you can see the difference between 4.2.3 and 4.2.6. As can be seen, the majority of changes only affect the docs. There are only minor changes in the source code, and they are the reason of the bug. V4.2.3 is the latest good-to-go version as of now.

P.S. I never used old templates, I started with v4.2.5 right away and the bug has already been there. So dear devs, please look into this. Thanks.

SantinoPetrovic commented 5 years ago

I think I've found the problem that causes it. On file: src/Submission/Handler/Redirect.php, look up this code: " public function refresh(Request $request) { $response = new RedirectResponse($request->getRequestUri()); return $response->send(); } " Remove return part of the line so it will be only: $response->send();. Why? I dunno... It's very weird for me that returning the response would cause it to not send the success message...

COOLak commented 5 years ago

I can confirm on the latest master build the issue is gone.

Please disregard this. The master build is ancient. On the latest version, which is 4.2.6, the issue persists. 4.2.3 is still the latest version unaffected.

dutty5 commented 5 years ago

I confirm that @SantinoPetrovic 's solution works (in v4.2.6). Thank you.

simplecreatif commented 5 years ago

Also can confirm @SantinoPetrovic 's fix worked perfect for me too on v 4.2.6 Thank you so much, this was driving me crazy and spent about 2 hours before finding this fix.

bobdenotter commented 5 years ago

Should be fixed in 4.3.0-beta.1, but it's still experimental. It'd be helpful if some more people could try it out, to test it in the field.

See: #284