Jump to content

Released: Street Address Fieldtype + Inputfield


netcarver

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...
image.png.82d89ad5a2e15d4f7d996f31a2c9c0e2.png

Link to comment
Share on other sites

@netcarver

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)...

<?php
$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)
image.png.ba0271090141a1cd792d7f2a7236553f.png

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

image.png.7c5b7580f06002c5b75f4f2a352b7f0a.png

This is the resulting format.

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

image.png.58319bc7994b470d21622b025eb4aeef.png

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

image.png.d3bb7e08630c64ef7f6b8fbca93a78a5.png 

Still, this is the resulting HTML:

image.png.e7bfb56092871f8df52fe0ee8771219b.png

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

image.png.d8506ab5acffe18d173914c22e045501.png

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...