When using Ubercart attributes on the paid event product and a page break component on the webform, the values of those attributes are reset when clicking the "Next" button on the webform. Additionally, the attributes show up on every page of the webform, whereas they should probably only show up once at the beginning or the end. Finally, a message that the form was submitted appears after clicking the "Next" button, although the form was not actually submitted and the results were not stored. Without the page break component, the process is working fine. Using Webform version 6.x-3.9.

Comments

andyf’s picture

Title: Attribute values reset when using Webform page break » Multipage forms don't work
Status: Active » Needs review
StatusFileSize
new6.11 KB

Ooh, I was just about to post a patch to fix event registration page break behaviour. I'm not using attributes and didn't really look at that aspect of the code. Let me know if this fixes it - if not, hopefully it'll be relatively painless to add it.

ChrisLaFrancis’s picture

Looks like the attributes are still showing up on every page and being reset. I am, however, no longer seeing the message about the form being submitted after clicking the "Next" button.

andyf’s picture

Thanks for the feedback fivefrank. I've done a modification to the patch but it's based on inspection only I'm afraid. I'm a bit busy at the mo so probably won't be able to look at it this week. Let me know if it works (fingers crossed!).

ChrisLaFrancis’s picture

Definitely getting closer. The attributes only appear on the first page of the webform, but by the time we make it to checkout, they're not affecting the price as they should, so I'm guessing their values are being lost.

Getting two errors in the log when the form is submitted:

Invalid argument supplied for foreach() in

/sites/all/modules/uc_event_registration/uc_event_registration.module
on line 188.

array_combine() expects parameter 1 to be array, null given in

/sites/all/modules/uc_event_registration/uc_event_registration.module
on line 193.

I really appreciate all the work you're putting into this.

andyf’s picture

Thanks fivefrank. I really don't have time to properly look at it. The error on line 188 is the problem:

foreach($form['#post']['uc_event_attributes'] as $key => $value){

I think $form['#post'] only contains the details from the latest page submission, which is why it doesn't contain page 1's attributes. I believe if you look in $form_state['values'] you should find it. So try replacing line 188 with

foreach($form_state['values']['uc_event_attributes'] as $key => $value){

If that fails try a dpm($form_state) and try to find the location of uc_event_attributes on the final page submission.
HTH
A.

ChrisLaFrancis’s picture

Thanks again for all your help. I couldn't find 'uc_event_attributes' in $form_state, but I was able to find it in $form... $form['#parameters'][1]['values']['uc_event_attributes'] seems to be working.

andyf’s picture

Great stuff! Would you be able to post the final patch for other users/module author?

ChrisLaFrancis’s picture

First time I made a patch using git. It's the same as your last patch with the exception of the one line that I changed. Thank you again.

ChrisLaFrancis’s picture

Actually just realized attributes values are still being lost if there are more than two pages in the webform.

ChrisLaFrancis’s picture

Checked $form and $form_state, and 'uc_event_attributes' just isn't present anymore by the time we make it to checkout if the webform has more than two pages.

andyf’s picture

Status: Needs review » Needs work

That's a shame. The place to look is in webform's submit handler. It's possible that the attributes were added to $form_state['storage'] and then removed by the final submit handler (otherwise the form wouldn't submit properly) before our submit handler's called. It could be that webform's just ignoring that data entirely (ie not copying it to $form_state['storage']) because it's not part of the webform, in which case we either want to write our own submit handler, or maybe we can hide the attributes amongst the webform components and get webform to store them for us. That's all I can think of at the mo. I can maybe take a look this weekend.

andyf’s picture

Status: Needs work » Needs review
StatusFileSize
new8.33 KB

This works for me, let me know if any problems.

Rob_Feature’s picture

This patch is now in the latest dev (April 18, 2011). Please test.

ChrisLaFrancis’s picture

Working for me also. Thanks for your hard work, AndyF.

Saoirse1916’s picture

Just wanted to confirm this works great for me as well. Thanks for a nice module!

andyf’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.