bolt / boltforms

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

bolt form success fails #202

Open ghispi opened 6 years ago

ghispi commented 6 years ago

I have bolt form with post processing on BoltFormsEvents::SUBMISSION_POST_PROCESSOR. Forms show correctly, its correctly validated, if not valid correct messages show but if form is valid it fails just after mine post processing. I've tried with feedback.success and feedback.redirect both fails the same way:

Uncaught Exception: Twig_Error_Runtime .

Twig_Error_Runtime in Template.php line 447: An exception has been thrown during the rendering of a template ("Attempted to access invalid result: boltforms.submission_post_processor") in "main-pages/join_page_form.twig" at line 6.

join_page_form.twig:

<div>
    {{ boltforms('join') }}
</div>

boltforms.bolt.yml:

join:
  notification:
    enabled: false
  feedback:
    success: Thank you!
    error: There are errors in the form, please fix before trying to resubmit
    redirect:
        target: page/thank-you
  templates:
    form: boltforms\join_form.twig
  fields:
...

It doesn't seem that boltforms/src/Submission/Result.php work with SUBMISSION_POST_PROCESSOR. Please advice if its my error in config or issue with bolt forms and how to deal with it.

Versions: bolt/bolt: v3.3.6 bolt/boltforms: v4.1.13

jvic commented 6 years ago

This issue still persists, had the same error on bolt v3.3.9 and boltforms v4.2.1. Is there a quick fix for it, or will it be my setup?

jvic commented 6 years ago

I may have found the error and the solution, please double check it.

extensions/vendor/bolt/boltforms/src/Submission/Result.php does not contain PRE and POST processing in the defined array:

    $this->result = [
        BoltFormsEvents::SUBMISSION_PROCESS_FIELDS      => false,
        BoltFormsEvents::SUBMISSION_PROCESS_UPLOADS     => false,
        BoltFormsEvents::SUBMISSION_PROCESS_CONTENTTYPE => false,
        BoltFormsEvents::SUBMISSION_PROCESS_DATABASE    => false,
        BoltFormsEvents::SUBMISSION_PROCESS_EMAIL       => false,
        BoltFormsEvents::SUBMISSION_PROCESS_FEEDBACK    => false,
        BoltFormsEvents::SUBMISSION_PROCESS_REDIRECT    => false,
    ];

Instead it should contan PRE and POST processing too:

    $this->result = [
        BoltFormsEvents::SUBMISSION_PRE_PROCESSOR       => false,
        BoltFormsEvents::SUBMISSION_POST_PROCESSOR      => false,

        BoltFormsEvents::SUBMISSION_PROCESS_FIELDS      => false,
        BoltFormsEvents::SUBMISSION_PROCESS_UPLOADS     => false,
        BoltFormsEvents::SUBMISSION_PROCESS_CONTENTTYPE => false,
        BoltFormsEvents::SUBMISSION_PROCESS_DATABASE    => false,
        BoltFormsEvents::SUBMISSION_PROCESS_EMAIL       => false,
        BoltFormsEvents::SUBMISSION_PROCESS_FEEDBACK    => false,
        BoltFormsEvents::SUBMISSION_PROCESS_REDIRECT    => false,
    ];

Also extensions/vendor/bolt/boltforms/src/Submission/Processor.php doesn't seem to contain PRE and POST processing in

private static $eventMap

But it did not cause any errors in my env.

remdan commented 5 years ago

I can confirm it, the same on bolt v3.6.4 whit boltforms v4.2.6

The input from jvic works... can we change it in the next releas!?

rossriley commented 5 years ago

sure, can you just re-target this PR to 4.2 and not master, then I'll merge and tag.