The add to cart form currently unsets form fields from the fields on the line item instead of using ['#access'] = FALSE' , this is much more inflexible in cases where a developer via form alter in some cases would like to display a form field that normally should be visible.

With the above change, you can simple change #access to TRUE, now you would have to use field_attach_form, is is more code/time consuming.

Comments

googletorp’s picture

Status: Active » Needs review

I've add a patch for this in my sandbox: 7aee316

rszrama’s picture

Status: Needs review » Fixed

Committed. Good catch.

rszrama’s picture

Gah, I knew there was a reason I was unsetting, but when I tried your code w/ Kickstart I didn't hit any problems. The real issues arise when you're using the product selector or attribute forms. Data from inaccessible form elements is still there in the submitted values even if I can't access it, making the Add to Cart form add whatever the default product of the form is to the cart every time.

I could either revert this or unset inaccessible field data before calling field_attach_submit(). For now I've chosen the latter approach, as it solves the issue and still leaves it flexible for the use case you mention. I'm just not sure if this would be considered a hack or not. (And fwiw, I've never liked the way inaccessible items work, but I digress.)

googletorp’s picture

Argh, sorry for the hazzle.

rszrama’s picture

No worries. I should've caught it but apparently missed the warnings from our test bot in #drupal-commerce or didn't get them in time. Easy enough to fix, and it lets me fix a failing test in the Tax Admin UI, too. ; )

Status: Fixed » Closed (fixed)

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

Anonymous’s picture

Issue summary: View changes

Fixed code formatting