Closed (fixed)
Project:
Commerce Core
Version:
7.x-1.x-dev
Component:
Developer experience
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
19 Jul 2011 at 08:32 UTC
Updated:
25 Aug 2011 at 15:32 UTC
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
Comment #1
googletorp commentedI've add a patch for this in my sandbox: 7aee316
Comment #2
rszrama commentedCommitted. Good catch.
Comment #3
rszrama commentedGah, 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.)
Comment #4
googletorp commentedArgh, sorry for the hazzle.
Comment #5
rszrama commentedNo 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. ; )
Comment #6.0
(not verified) commentedFixed code formatting