I need to create a custom form and in it there is an address but I can't figure how to use the address field form.

There is a way to use the address structure defined in the Address field module?

  • Welcome to the painful world of adding a field widget as a FAPI element :) I can vouch for the methods in the duplicate post, I've actually used one of them with an addressfield successfully (I forget which one but I think it was Scott Joudry's answer that won out eventually)
    – Clive
    Oct 16, 2013 at 9:43
  • Thank you for the answer but I need to extract it from a 'billing' entity not a node ^^
    – Shyghar
    Oct 16, 2013 at 9:53
  • The methods in the dupe post are completely entity type-agnostic - you can use them with any type, just replace "node" with whatever entity you need to get the data from. Building the dummy entity will differ slightly, but essentially you just need a stdClass with the appropriate entity bundle keys set
    – Clive
    Oct 16, 2013 at 9:54
  • Yep but if I create a node through node_object_prepare($entity) I cannot use field_attach_form("billing", $entity, $temp_form, $temp_form_state).. and a billing_object_prepare() do not exist.
    – Shyghar
    Oct 16, 2013 at 10:00
  • node_object_prepare() is node-specific, other entities don't have an equivalent because they don't need one. I'd really recommend giving it a go, it definitely works.
    – Clive
    Oct 16, 2013 at 10:03


Browse other questions tagged or ask your own question.