In the Webform Pay issue queue, we've found a way to have failed transactions send the user right back to the page they were on without losing form information. So on a multiple page form, the user is sent back to the last page with all their information intact (except the Pay field, which clears itself).
However in Webform we keep track of which page the user is on and all the current values in $form_state['storage']. If the transaction fails, we need that information to still be there so the user can correct the mistake and submit the form again. In Pay's submit() method's though, $form_state['storage'] is entirely unset(). I can't find a reason for this however, as Pay doesn't actually put anything into storage so it shouldn't be removing it.
Even if Pay *did* put something into storage, a safer approach would be putting everything into $form_state['storage']['pay'] = array(), then just unsetting the single part of the storage that Pay inserted into storage. Then other modules (like Webform) can manage their own storage without Pay removing everything.
For the time being though, I've simply removed the calls to unset() entirely, since $form_state['storage'] isn't used in any way, there's no need to unset() it.
| Comment | File | Size | Author |
|---|---|---|---|
| pay_unset_storage.patch | 1 KB | quicksketch |
Comments
Comment #1
beetlecat commentedThis in encouraging reading. I'm very glad for your attention to this project and the inter-operability between the main players.
Comment #2
agileadamI've applied your patch
and it worked beautifully. Now, when I click "Previous Page" it maintains the values from the first page of the form.Comment #3
agileadamWhoops. I've found a problem. When I apply this patch, the following workflow breaks:
1) Fill out data on page 1, click "Next Page"
2) Page 2 loads
3) Click "Previous Page"
4) Values are there now, yay!
5) Click "Next Page"
6) Form submits, completely! AAAH :(
Just to check, I reverted the patch. Clicking "Previous Page" goes back, but values are not preserved (back to square one). However, if I click "Next Page," I'm taken to page 2 and the form is NOT submitted into the DB (this is a good thing).
So it seems we need the best of both worlds. I'll keep messing with things...
Comment #4
quicksketchkeystr0k: Did you apply both this patch and the patch in #1038436: Handling of failed transactions? Both are needed to get Webform Pay handling failed transactions correctly.
Also, Webform Pay does not handle the Payment information being on any page except the last page still, even after these patches.
Comment #4.0
quicksketchFixing typo s/looking/losing.