Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi,
I've altered a product form using hook_form_alter, adding two fieldsets in which the first shows some text and hidden input and the second a file upload field, implemented with managed_file.
I'm using hook_uc_add_to_cart_data to manage input from the form. When I only have hidden and text fields everything goes fine (even if the hook is called twice), but when I upload a file the other fields become empty: $form_values does not contain any more custom data, like if it was sent with the ajax file submit.
'Solved' using type file instead of managed_file, for now.
Comments
Comment #1
longwaveNot sure why this is a bug report, nor what we can do about it in Ubercart? If there is a problem with managed_file it should perhaps be reported against Drupal core? Your custom code might be helpful too, but in general we don't support custom code in this issue queue.
Comment #2
fininho CreditAttribution: fininho commentedThanks for your answer.
It seems a bug to me as I loose form data, and I don't think it should happen. I don't know if this is a Drupal issue due to the way form data are handled, or a Ubercart issue due to the values passed to hook_add_to_cart_data, so I posted it here under Ubercart project.
Comment #3
longwaveIf you post your code someone may take a look at it, perhaps even it would be useful in order to get a 'file' product attribute into Ubercart eventually.
Comment #4
fininho CreditAttribution: fininho commentedHere's the code, hoping someone finds it useful.
Comment #5
longwaveI guess this may need special handling in the same way that system_settings_form() does not handle managed_file properly either: #1090198: managed_file form item in system settings form causes error in form_state_values_clean()
Leaving active for now as I think we have enough info, but someone needs to take the time to debug this further.
Comment #6
longwavePretty sure this is a core issue related to managed_file inside fieldsets, #1957602: managed_file inside fieldset returns 0 upon submission without previous upload sounds very similar as well. Please reopen only if you are sure this is an actual problem with Ubercart.