This is verbatim from our sprint discussion notes...

Investigate: Instead of storing checkout pane validate handlers in $form['#validate'], store them in the fieldset's $form['pane']]['#pane_validate'] array. In the submit step, run the validation for each fieldset and then process the submit handlers for any panes that pass validation. This allows the form to be rebuilt if part of it fails validation. The problem might be, though, that we need to then repopulate fields on the form with the invalid values when we rebuild it... and we don't know where the invalid values would come from. : )

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

rszrama’s picture

I believe Damien has done this, but we still need to implement the AJAX loading of the same page...

rszrama’s picture

Assigned: Unassigned » Damien Tournoud
Issue tags: -dcsprint3 +dcsprint6

Let's decide if this needs to happen for RC1, too. We've survived so long without it that I'm not sure it's necessary...

Damien Tournoud’s picture

Status: Active » Needs review

We are nearly there. There is actually one small change necessary here: when a form fails validation (for example because a required element is not present) no pane are processed.

Fixing this looks easy, see the 7.x-1.x-842292 branch.

rszrama’s picture

Damien Tournoud’s picture

Issue tags: +1.1 blocker
Damien Tournoud’s picture

Here is a reroll.

Damien Tournoud’s picture

FileSize
27.13 KB

This patch moves the pane validation / submit logic from a form submit where it currently lies to a form validate.

This allow us to properly validate and submit panes independently one from the other. One visible change for this is that error messages related to required fields are now properly showing attached to every pane:

Status: Needs review » Needs work

The last submitted patch, 842292-checkout-form-validation.patch, failed testing.

rszrama’s picture

Status: Needs work » Needs review
FileSize
3.8 KB

I've attached an update that'll pass the testbot (conflict with the recently committed patch to fix messages in checkout). I also brought back the submit handler to actually handle message restoring between page redirects and to set the redirect URL. This code came after an if check in the old handler that required validation to pass... so it was basically the actual submission part of the old submit handler.

The only thing I don't know is if you'd want me to clear the submit handlers at the end of the checkout form builder function like you do for the validate handlers. Interested to see what the test bost says. My local tests all worked great.

Status: Needs review » Needs work

The last submitted patch, 842292-9.checkout_validate.patch, failed testing.

rszrama’s picture

Just a note to say that I'm debugging those fails; as far as I can tell, they're related to the fact that making validation actually happen in a validation handler now means we have to accommodate AJAX posts which, in the case of the failing test, only includes an update to a country. If this is changed on the same page as an invalid e-mail address, we don't have the proper contents in the messages array in the form state for the pane.

rszrama’s picture

Status: Needs work » Needs review
FileSize
4.52 KB

Alrighty, what was happening was this code was replacing the stored messages array with rendered HTML at a time when that stored messages array would still need to be accessed again in a subsequent AJAX validation in which the previous errors are still present:

      // If there are messages in the session right now for this pane, theme
      // them into the form right above the pane itself.
      if (!empty($_SESSION['messages'])) {
        $form_state['storage']['messages'][$pane_id] = theme('status_messages');

        $form[$pane_id . '_messages'] = array(
          '#markup' =>  $form_state['storage']['messages']['messages'][$pane_id],
        );
      }

It could be we don't need to store the themed output in the form state or even that we could work some bypass into this during AJAX validation, but I'm trying to preserve the intent of the original patch by just putting the themed output in a separate 'themed_messages' array.

Also, I went ahead and set the form level #submit handlers like you did for #validate.

All clear, test bot and Damien bot?

Status: Needs review » Needs work
Issue tags: -dcsprint6, -1.1 blocker

The last submitted patch, 842292-12.checkout_validate.patch, failed testing.

rszrama’s picture

Status: Needs work » Needs review

#12: 842292-12.checkout_validate.patch queued for re-testing.

Status: Needs review » Needs work
Issue tags: +dcsprint6, +1.1 blocker

The last submitted patch, 842292-12.checkout_validate.patch, failed testing.

rszrama’s picture

Status: Needs work » Needs review
FileSize
4.51 KB

Test bot is out of disk space. Just as well since I had a typo. :-/

rszrama’s picture

In case that fails provisioning again, this passed testing locally. If I don't hear any negative feedback, I'll commit this later today. It doesn't change any logic from your original patch that I can see and simply moves the submit handlery type stuff into a legit submit handler.

rszrama’s picture

Status: Fixed » Closed (fixed)
Issue tags: -dcsprint6, -1.1 blocker

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