Address format API in Address Field 7
API for generating address forms and display formats.
Addresses forms and display formats are collaboratively generated by one or more format handler plugins. An address with a name and a company, for example, will be generated by three handlers:
- 'address' that will generate the country, locality, street blocks
- 'organisation' that will add the organisation block to the address
- 'name-full' that will add a first name and last name block to the address
A format handler is a CTools plugin of type 'addressfield' / 'format'. Each handler is passed the format in turn, and can add to or modify the format.
The format itself is a renderable array stub. This stub will be transformed into either a Form API array suitable for use as part of a form or into a renderable array suitable for use with drupal_render(). The following modifications are done:
- when rendering as a form, every element which name (its key in the array) is a valid addressfield column (see addressfield_field_schema()), will be transformed into a form element, either using a type explicitly defined in '#widget_type' or using 'select' if '#options' is set or 'textfield' if it is not. In addition, the '#default_value' of every field will be populated from the address being edited.
- when rendering as a formatter, every element which name (its key in the array) is a valid addressfield column (see addressfield_field_schema()), will be transformed into a renderable element, either using a type explicitly defined in '#render_type' or else using 'addressfield_container'. When the type is 'addressfield_container' the element will be rendered as an HTML element set by '#tag' (default: span).
File
- ./
addressfield.module, line 117 - Defines a field for attaching country-specific addresses to entities.
Functions
Name | Location | Description |
---|---|---|
addressfield_generate |
./ |
Generate a format for a given address. |
addressfield_process_format_form |
./ |
Generate a full-fledged form from a format snippet, as returned by addressfield_formats(). |
addressfield_render_address |
./ |
Render an address in a given format. |
CALLBACK_addressfield_format_callback |
./ |
Format generation callback. |
_addressfield_process_format_form |
./ |
|
_addressfield_render_address |
./ |