boltforms icon indicating copy to clipboard operation
boltforms copied to clipboard

result.pass('email') is always false before and after form submission

Open nestordedios opened this issue 8 years ago • 2 comments

Hi! I don't know if this is a bug or that I might be doing things wrong, but after I submit a form I get the feedback success message together with the form which I didn't expect.

Details

  • Relevant BoltForms Version: 4.1.14
  • Relevant Bolt Version: 3.4
  • Install type: Composer install
  • PHP version: 5.6
  • Used web server: Apache

Reproduction

I have installed BoltForms 4.1.14 and I'm using the default BoltForms templates and the default contact form in boltforms.bolt.yml.

To reproduce the issue fill in the form and submit. After submitting the form if the submission is successful the expected result would be to see the info messages and no form anymore.

In this line https://github.com/bolt/boltforms/blob/99199b0e58557bb43160f73549b32d8cfb5d33ec/templates/form/form.twig#L38 it seems that result.pass('email') is not returning true when a form is submitted successfuly.

Is this a bug or is there a workaround for this?

Thanks!

Not submitted form screenshot: notsubmittedform Submitted form screenshot: submittedform

My boltforms.bolt.yml for that form:

contact:
    submission:
        ajax: false                   # Use AJAX for form submission and handling
    notification:
        enabled: true
        debug: false
        debug_address: [email protected] # Email address used when debug mode is enabled
        debug_smtp: true
        subject: Your message was submitted
        from_name: name                # Email addresses and names can be either the
        from_email: email               # name of a field below or valid text.
        replyto_email: email            #
        replyto_name: name              # NOTE: Email addresses must be valid
        to_name: My Site                #
        to_email: [email protected]   #
    feedback:
        success: Message submission successful
        error: There are errors in the form, please fix before trying to resubmit
    fields:
        name:
            type: text
            options:
                required: true
                label: Name
                attr:
                    placeholder: Your name...
                constraints: [ NotBlank, { Length: { 'min': 3, 'max': 128 } } ]
        email:
            type: email
            options:
                required: true
                label: Email address
                attr:
                    placeholder: Your email...
                constraints: [ NotBlank, Email ]
        message:
            type: textarea
            options:
                required: true
                label: Your message
                attr:
                    placeholder: Your message...
                    class: myclass
        needreply:
            type: choice
            options:
                required: false
                label: Do you want us to contact you back?
                choices: { 'Yes': 'yes', 'No': 'no' }
                expanded: true
                multiple: false
        submit:
            type: submit
            options:
                label: Submit my message »
                attr:
                    class: button primary

nestordedios avatar Dec 14 '17 13:12 nestordedios

This one could be a bit of a bug since I'm not sure testing the email processor is always the best idea

The crux is that something has gone wrong with the email send, it could be that one of your email addresses (in any field to/from/cc/bcc) fails validation, or even another exception with the smtp or mail command somewhere along the line.

If all those are ok then it is possible to get the success message and result.pass('email') then evaluates to true.

rossriley avatar Feb 21 '18 13:02 rossriley

The redirect handler called at the end of lifecycle always redirects - that would unset the result? Maybe needs to be stored in a session before the redirect happens?

mikenosko avatar Feb 21 '18 13:02 mikenosko