Jump to content

Released: Street Address Fieldtype + Inputfield


Recommended Posts

Yeah, I can understand that, but I was going for a pretty opinionated input look - in part to try and provide a slick (fast) keyboard entry method for users at the charity - that really mimics an address label.

Please feel free to share your "vanilla" CSS and whatever your findings are regarding getting it working with map marker modules - I know there will be some others in here who are interested in such an integration.

  • Like 1
Link to comment
Share on other sites

  • 1 month later...
  • 1 year later...

This is a really useful module. I have only had one issue so far - the default country setting in the field config page does not seem to work in the API. I have to set (e.g.)

$this->address->origin_iso = 'GB';

for it to be effective.

Link to comment
Share on other sites

A bug? (version 1.1.2)

On selecting a subfield in a lister and typing in the value to match, I get the error "Call to a member function isEmpty() on string" for line 55 of FieldtypeStreetAddress.module

Link to comment
Share on other sites

  • 7 months later...
  • 2 years later...

First of all: thanks for this field, it's great.

How can I override the ISO used for rendering the field? It always comes out as the wrong format (City, Zip) despite only "German" (Zip City) being present in the field options.

I've resorted to just overriding the iso codes at the start of "formatLines()", but that's dirty as hell.

Is there a way to set the formatting language when/before getting the field value from the page?

Link to comment
Share on other sites

@clemens Thank you for the +ve feedback. I'm not sure I understand the issue you are having based on your description, but you can easily override the output formats, which are pulled from Google's LibAddressInput project, by simply editing the example.formats_overrides.php file in the FieldtypeStreetAddress/ directory. You'll need to look at the "Reading the JSON" section of the LibAddressInput project documentation to see what each of the fields is. In case it's not obvious, "%n" is a newline.

This might allow you to do what you are after but, if not, please post again.

Here's what one of my local DE-based addresses looks like - with no changes to the defaults from Google. This seems to have things in ZIP CITY order...

Link to comment
Share on other sites


Thanks for replying so quickly.

The address is displayed correctly in the preview when editing the page. The issue comes when outputting the field/getting the field value via $page->get("address_field"). I alway get "city, zip" in the resulting html.

How is the localization determined here? Is it the language ProcessWire is set to? Can I force the field to output German localization here as well?

Link to comment
Share on other sites

If you put this in your template file, just before you try outputting the address, what do you get? (Remove the PHP tags if you need to, and/or add nl2br() around the output to make it prettier)...

$country = 'DE';
$format  = var_export(StreetAddress::getFormat($country), true);
echo "Format for $country is [$format]";

Here's what I get locally (run from the command line though)

The other thing to check is that the address you are formatting is actually tagged up with Germany as the destination country?


Link to comment
Share on other sites


This is the resulting format.

The address itself should be German since only Deutschland is allowable.


I've also set all addresses as domestic and the country of origin as DE, too.


Still, this is the resulting HTML:


It only displays properly when I do this to your module:


Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...