Hi,

When creating an order using the admin UI, if the order contains required fields (such as "Terms of Use"), adding a line item is prevented by validation error.
I think of it as only a minor issue, as we can clearly check the tick-box, but still, it does not seem to be a good UX practice ;-)

Comments

rszrama’s picture

I tried to apply a quick fix by adding #limit_validation_errors to the action buttons in the line item manager widget form. This should have worked, but it isn't. I don't know why yet.

Simon Georges’s picture

I had the same reaction, and as the quick fix didn't work, I posted the issue, thinking you'll be better equipped to fully fix it. Sorry about that ;-)

rszrama’s picture

hehe No worries, I love a challenge. : P

rszrama’s picture

Status: Active » Fixed

Well, I was able to get to the bottom of this. The idea is that a submit element type defaults #executes_submit_callback to TRUE, indicating that clicking the submit results in a form level submission. The form validation process checks this value and decides the form has been submitted unless the submit element specifies its own #submit callback(s). However, the button element type defaults #executes_submit_callback to FALSE, indicating that a click of that button isn't considered a form submission.

The difference is that #limit_validation_errors will be completely ignored if the form validation process decides the form is being submitted. This has worked by accident for the checkout form where we limit validation errors, because we always had a #submit callback for those buttons. However, for the line item manager widget, we don't have #submit callbacks, so changing these to button elements will be sufficient for our #limit_validation_errors values to be respected. : )

For the "Add line item" and "Save" buttons, we still validate child elements in the line item manager widget.

Commit: http://drupalcode.org/project/commerce.git/commitdiff/c825f26

Simon Georges’s picture

Wow, nice catch! This should be documented somewhere on the Form APi, don't you think (or is it already?)?

rszrama’s picture

It kind of is. There's an italicized remark that #limit_validation_errors will be ignored if #submit isn't set on the element, but what it doesn't say is that this is only true in the case of submit elements, not button elements.

Status: Fixed » Closed (fixed)

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