Download & Extend

The delete button in the cart should not trigger form validation

Project:Drupal Commerce
Version:7.x-1.x-dev
Component:Cart
Category:task
Priority:normal
Assigned:Unassigned
Status:needs review

Issue Summary

Delete buttons are not supposed to trigger form validation.
However, the Delete button provided by Commerce doesn't set #limit_validation_errors, leading to possible validation errors on delete (more frequent when there are additional custom form elements in the cart).

Comments

#1

Status:active» needs review

Here's a oneline patch.

AttachmentSizeStatusTest resultOperations
1895682-cart-delete-button-validation.patch894 bytesIdleFAILED: [[SimpleTest]]: [MySQL] 3,570 pass(es), 0 fail(s), and 2 exception(s).View details | Re-test

#2

Status:needs review» needs work

The last submitted patch, 1895682-cart-delete-button-validation.patch, failed testing.

#3

Category:bug report» task

Why shouldn't it trigger validation? It's a submit button on the form, and if someone changes a quantity on another line item I wouldn't want their value to be lost by removing something else in the cart. So I'd say this is by design, but if you had a rationale for the change I'd be happy to entertain it.

Obviously, if this were just a delete button at the bottom of a line item entity form, we'd want it to limit validation errors. But as just one element of many on a form, I don't see why we would. I may be misunderstanding the form, though - perhaps it's using a button level submit handler so quantity values wouldn't be saved anyways?

#4

perhaps it's using a button level submit handler so quantity values wouldn't be saved anyways?

Exactly.

EDIT: Hm, I was wrong. Right now clicking Delete will save other quantities. However, I consider that to be wrong. If you didn't update your cart, Delete shouldn't be doing that for you.

#5

Ahh, interesting. It's how the "Checkout" button works, too.

#6

Status:needs work» needs review

Here is a smarter patch.

Effects:
1) Delete doesn't trigger validation errors. It just removes the row. Quantities are not updated.
2) Quantities are updated when one of the main buttons is clicked (Update cart, Checkout)

AttachmentSizeStatusTest resultOperations
1895682-cart-delete-button-validation-6.patch6.69 KBIdlePASSED: [[SimpleTest]]: [MySQL] 3,570 pass(es).View details | Re-test

#7

Rerolled patch against dev.

AttachmentSizeStatusTest resultOperations
1895682-cart-delete-button-validation-7.patch6.28 KBIdlePASSED: [[SimpleTest]]: [MySQL] 3,557 pass(es).View details | Re-test
nobody click here