Download & Extend

Patch Field API to accommodate Fields nested in #tree arrays

Project:Drupal Commerce
Version:7.x-1.x-dev
Component:Customer
Category:feature request
Priority:normal
Assigned:Unassigned
Status:closed (fixed)
Issue tags:low-hanging fruit

Issue Summary

The checkout form uses a #tree to organize elements on the form beneath the checkout pane they are included on. This breaks the customer checkout pane because it includes an entity form with field elements. The field's widget form looks in the form state at a particular point to detect the element's settings when refreshed via Javascript (using the #ajax feature), which won't work for this nested array. It would be great to avoid the hack we currently have (of stuffing field values into the top level of the form state array) and instead patch the Field API to find the right values for the element within the nested #tree array.

See commerce_customer.checkout_pane.inc lines 32 ff.

Comments

#1

As with the payment method validate handler, I'm wondering if we can't just pass in the parent keys in the form array... see what I've done in this commit to ensure we can properly set form errors:

http://github.com/rszrama/drupalcommerce/commit/ba14cae61603e107fafb2480...

#2

Status:active» fixed

Indeed, parsing #array_parents and #parents did the trick. Look at addessfield_field_widget_form(), addressfield_standard_widget_validate(), and addressfield_standard_widget_refresh() in Address Field for a working example.

#3

Status:fixed» closed (fixed)

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