Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Single-page webform won't complete (when 'page_num' is equal to 'page_count') #170

Open
jenlampton opened this issue Oct 29, 2020 · 2 comments · May be fixed by #171
Open

Single-page webform won't complete (when 'page_num' is equal to 'page_count') #170

jenlampton opened this issue Oct 29, 2020 · 2 comments · May be fixed by #171

Comments

@jenlampton
Copy link
Member

I'm having a problem with a webform that won't complete when it's submitted, it just keeps reloading the same page.

Here's my use case: I have [some reason] that I need to attach the submit handler to the submit button, rather than doing it in ['#submit'], but when I add them both here, the form won't complete.

My code:

  $form['actions']['submit']['#submit'] = array(
    'webform_client_form_pages',
    'webform_client_form_submit',
  );

I get to this part of the code in webform_client_form_pages() and it fails...

// The form is done if the page number is greater than the page count.
    $form_state['webform_completed'] = $form_state['storage']['page_num'] > $form_state['storage']['page_count'];

...because 'page_num' is equal to 'page_count'. Then, when webform_client_form_submit() fires, it bails out immediately because $form_state['webform_completed'] is FALSE.

Switching the greater-than check to greater-than-or-equal-to fixes my problem, but I wonder if there are risks to making this change? Why was it expected to be greater?

(On this site I only have single-page webforms)

@jenlampton jenlampton changed the title Webform won't complete Webform won't complete (custom code use-case) Oct 29, 2020
jenlampton pushed a commit to jenlampton/webform that referenced this issue Oct 29, 2020
@jenlampton
Copy link
Member Author

I've filed a PR at #171, but It needs to be tested on multi-page webforms to see if there are any adverse effects.

@herbdool
Copy link
Collaborator

You could also put in debugs and look at the incrementing numbers for both page_num and page_count to see how they change with each page. That might reveal why it's set this way.

@jenlampton jenlampton changed the title Webform won't complete (custom code use-case) Single-page webform won't complete (when 'page_num' is equal to 'page_count') Aug 15, 2022
robertgarrigos added a commit to robertgarrigos/webform that referenced this issue Dec 5, 2022
Issue backdrop-contrib#170: Check if current page is greater than or equal to page co…
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants