Hello,

When i submit a form on the checkout page, and one of input is marqued "required" and they doesn't have a value in this input, the error is been showed in messages, but the input doesn't have a "error" class.

It's a problem with my install or not ?

Sébastien

Comments

sebyoga’s picture

StatusFileSize
new23.17 KB
new10.29 KB
rszrama’s picture

Version: 7.x-1.0 » 7.x-1.x-dev
Status: Active » Postponed (maintainer needs more info)

Yeah, I confirmed this earlier, but I'm not sure there's anything we can do about it in conjunction with the error message trapping we do to put error messages inline with their related checkout panes. I imagine that's what prevents the errors from being detected. Any idea if there's a way to still support the error class without losing this functionality?

sebyoga’s picture

I have found where is the problem on the code and i post this patch. Can you test this patch ?

The correction is in file : commerce/modules/checkout/includes/commerce_checkout.pages.inc on line 298. (I removed this line)

I don't understand the reason of this line...

Sébastien

rszrama’s picture

Testing your patch out, it does fix the classes but prevents the error messages themselves from showing. We clear out the static cache here with this line to be able to move the error messages inline in our checkout panes. What I think we need to do is perhaps trap the form errors during validation and replay them during form building and trap the status messages then or something... not entirely sure after playing with it for 10 or 15 minutes.

LoyC’s picture

Why is this postponed? I can confirm this problem.

rszrama’s picture

It's pending based on my comments above, basically we need to determine if we can actually fix the classes while preserving our error trapping.

roderik’s picture

Issue summary: View changes
Status: Postponed (maintainer needs more info) » Needs review
StatusFileSize
new2.27 KB

You can. Luckily, _form_set_class() still matches the error correctly. It just expects the #validated property to be set (which isn't done in form rebuilds).

But we can set #validated ourselves without causing damage.

mariooo’s picture

Confirming roderik's patch works.

If you need this fix now, in lieu of hacking contrib in the meantime, this patch works equally well by implementing hook_form_commerce_checkout_form_checkout_alter.

Simply populate $form['#after_build'] for the checkout form with your own copy of the commerce_checkout_form_process_errors and _commerce_checkout_set_validated functions from the patch (watch out for the recursive call in _commerce_checkout_set_validated if renaming!).

yce’s picture

Patch at #7 works like charm, thanks!

halth’s picture

Confirming that patch at #7 works like a charm also!
Thank you @roderik!

pcambra’s picture

Status: Needs review » Reviewed & tested by the community

Confirming that @roderik patch fixes the problem.

The last submitted patch, 3: commerce-checkout-input-class-error-2023491-3.patch, failed testing.

luksak’s picture

Works for me as well. Let's get this committed!

rszrama’s picture

Status: Reviewed & tested by the community » Fixed

Fantastic patch, Roderik. Sorry this took so long to commit!

  • rszrama committed bea358f on 7.x-1.x authored by roderik
    Issue #2023491 by roderik: ensure error classes are set on form elements...
anrikun’s picture

Status: Fixed » Active

It doesn't work on date fields :-(

rszrama’s picture

Status: Active » Fixed

I don't see why it wouldn't... perhaps date is expanding its form elements later than #after_build is actually processing? I actually haven't seen date fields on a checkout form before; how are you getting them in there? Might need a separate follow-up task that's specific to the field type.

anrikun’s picture

I'll investigate further :-)

Status: Fixed » Closed (fixed)

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

joelpittet’s picture

The inc pages aren't loaded into the registry. And if you are using panels or something that function commerce_checkout_form_process_errors() doesn't exist in the ajax call.

Looking into ways to fix this... opened up a follow-up issue.
#2416921: Fatal error: Call to undefined function commerce_checkout_form_process_errors when displayed through Panels