About Street Address
Fieldtype to store a street address and allows access to its subfields.
|Category 1||Field Types|
Fieldtype modules that represent a data type used by fields.
|Category 2||Input Fields|
Inputfield modules that provide a UI input widget in the ProcessWire admin.
Close to stable, but users are advised to be cautious and test thoroughly.*
|Date Added||September 8, 2018|
|Last Updated||April 30, 2019|
This module's files should be placed in /site/modules/FieldtypeStreetAddress/
How to install or uninstall modules
Inputfield and storage for addresses in ProcessWire. Based upon the address meta data from Google's libaddressinput project.
- A working PW3+ installation.
- Install using module class name of "FieldtypeStreetAddress"
- Create a new directory under your
site/modulesfolder called "FieldtypeStreetAddress"
- Save the files from this package into the new directory.
- Log into your PW admin interface and go to Modules > Refresh and then install the "FieldtypeStreetAddress" & "InputfieldStreetAddress" modules.
You should now be able to create a new field and assign it the type "StreetAddress". Add it to a template to be able to see it in action.
There are two separate sections - Input Options and Output Options.
This is a multiselect control that allows you to specify what choices of destination country the user has in the inputfield. If all your addresses are going to a single country (probably your own), then choose it here.
If there are a range of possible desitnations, you can either leave this field blank (in which case the user choice is unrestricted), or choose a set of options (in which case choice is limited to this set)
If you allow a choice of more than one country, then you will be able to choose the default country here. NB, This option is added to the set of allowable destination countries if needed.
You can select between a dynamic field layout, that changes when (and if) you change the destination country, or a fixed, tabular input layout.
The dynamic layout of address subfields is driven by the country address format string cached from the google i18n data feed. The tabular layout is fixed, no matter what destination contry you choose.
If you've chosen the dynamic layout option, you can also choose to show a preview of the formatted address output.
These control how the output of this field will be formatted. The layout of the formatted address always depends upon the cached layout data from Google, but some aspects of the output can be tweaked here.
You can choose to include HTML spans implementing schema.org's PostalAddress microformat.
Controls how the lines of the output are merged, either into a single line address, or into a multiline address.
NB Lines in the output are delimited by a single "\n" character unless you have chosen inclusion of HTML spans, in
which case the line delimeters are
<br>\n, which are suitable for output in HTML5. If you output this within a
<pre> element, you will see double line spacing. If you have your field setup to just output plaintext, and then
show this in an HTML element other than a preformatted block, you will see the text as a single line.
If you are sending mail domestically, it usually isn't necessary to include the destination country - but you can choose to tweak how this is decided here.
You can choose to never show the value, to always show the value, or to conditionally show the value.
Conditionality depends upon the country-of-origin field. If the country of origin differs from the country of destination in the address, then the address is assumed to be going via international post and the address field will be appended.
Select the country-of-origin from the list. This is the country from which you will be sending any physical mail.
As with all ProcessWire templates, you can output the formatted value in your template files by referencing the field:
The returned value will, by default, be laid out according to the address meta data from the Google feed, honouring your options for destination country inclusion, HTML tags and multi-vs-single line. It will also have any substitutions already made in it by the Tag Parser module.
If you access the field with PWs output formatting turned off, then the address you get back will honour the settings for the inclusion (or otherwise) of the destination address but will ignore settings for singleline, HTML spans and field substitutions via the tag parser. It's up to you to do what you need with it in these cases.
If you need to customise the output in your template files - or set values, you can get at the underlying StreetAddress
object via the
$address_object = $page->getUnformatted('client_address');
The files formats.php and countries.php are derived from LibAddressInput meta data and are released under the Apache-2.0 license as that seems to be what the project is using.
All other files are released under the MIT license.
- Admin Helpers
- Core Modules
- Development Tools
- Field Types
- Input Fields
- Language Modules
- Language Packs
- Markup Generation
- Premium Modules
- Process Modules
- Proof of Concept
- Site Profiles
- Social, Feeds, Services
- Text Formatters
- Other Modules
- Users and Access
*Use modules at your own risk. There are no guarantees or warranties. It is recommended that you backup your site and database before installing new modules.