Closed (fixed)
Project:
Commerce Core
Version:
7.x-1.x-dev
Component:
Checkout
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
5 Aug 2010 at 21:27 UTC
Updated:
23 Jul 2015 at 00:09 UTC
Jump to comment: Most recent
Comments
Comment #1
damien tournoud commentedThat's because you cannot use a standard required field in the current checkout logic. Checking the required fields should happen manually in the pane validation handler. This way, the pane itself fails validation, but not the whole form.
I'm wondering if we could implement the
'panes (ie. sub-forms) independently validate and submit'logic in a less hackish way then our current "do everything in the main form submit handler" strategy. I'll experiment to see how much code would be necessary to make it play nice with standard form validation (especially #require-ed elements and #element_validate functions, which we cannot use at all in the current system).Comment #2
rszrama commentedOn a side note, we could use #limit_validation_errors on the back button to suppress #required errors. The drawback is we'd need a custom submit handler for the back button that doesn't attempt to save data from the various panes on the page - trying to save invalidated data would be disastrous.
So the trade off is we could use actually required fields with a simple workaround for the back button but not capture data that might have been entered on the present page. A better solution that allows that might be forthcoming, but this seems like an acceptable trade off for 1.0 to me. Thoughts?
Comment #3
rszrama commentedOk, I've implemented a solution using #limit_validation_errors for now. This gets us around the root issue without requiring every checkout pane that wants to have required fields implementing their own solution to validate the field and indicate to the end user the field is required.
If we decide to pursue this further, the proper solution would be to alter the checkout form once constructed so that all elements with #required == TRUE would be changed via a central function to set #required = FALSE, still display a required indicator, and use a validate handler for the element to check for a value. However I will add that the way it functions now will match customer expectations, which is never a bad default behavior. : )
Commit: http://github.com/rszrama/drupalcommerce/commit/aedbbb2bc14f4b3c90bc5a8d...
Comment #5
bgilhome commentedI've found that the only case #limit_validation_errors doesn't work for is a checkout page containing a commerce_payment_pane. As a slightly hacky workaround, you can attach an onclick or some js to the Back button in this case via a hook_form_alter: