2017 © Pedro Peláez
 

silverstripe-module silverstripe-addressfinder

SilverStripe FormField for AddressFinder.co.nz

image

fullscreeninteractive/silverstripe-addressfinder

SilverStripe FormField for AddressFinder.co.nz

  • Monday, October 2, 2017
  • by wilr
  • Repository
  • 1 Watchers
  • 0 Stars
  • 777 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 3 Versions
  • 11 % Grown

The README.md

AddressFinder for Silverstripe

Scrutinizer Code Quality Latest Stable Version, (*1)

Maintainer Contact

  • Will Rossiter

Overview

This module provides a custom Silverstripe AddressFinderField which implements the javascript AddressFinder widget (1) for address and postcode lookups in New Zealand and Australia., (*2)

Getting Started

composer require fullscreeninteractive/silverstripe-addressfinder

app/_config/addressfinder.yml, (*3)

FullscreenInteractive\SilverStripe\AddressFinderField:
  api_key: 123

Or, use environment variables if you prefer:, (*4)

app/_config/addressfinder.yml, (*5)

FullscreenInteractive\SilverStripe\AddressFinderField:
  api_key: '`ADDRESS_FINDER_KEY`'

Then add an instance of AddressFinderField to your form fields, (*6)

use FullscreenInteractive\SilverStripe\AddressFinderField;

$fields->push(new AddressFinderField('Address'));

This will provide your form with a single text box that provides an autocomplete dropdown as well as a toggle for the user to enter a manual address in the event the API is inaccessible., (*7)

The form field provides the saveInto logic for automatically saving into a DataObject model if defined. The fields that the module will save too (if in the database) are, (*8)

  • Address single line representation, should be the name of your field
  • PostalLine1
  • PostalLine2
  • PostalLine3
  • PostalLine4
  • PostalLine5
  • PostalLine6
  • Suburb
  • City
  • Postcode
  • Latitude
  • Longitude

An example model which will capture all the information from AddressFinder is outlined below:, (*9)

<?php

use SilverStripe\ORM\DataObject;

class AddressObject extends DataObject
{
    private static $db = [
        'Address' => 'Text',
        'PostalLine1' => 'Varchar(200)',
        'PostalLine2' => 'Varchar(200)',
        'PostalLine3' => 'Varchar(200)',
        'PostalLine4' => 'Varchar(200)',
        'PostalLine5' => 'Varchar(200)',
        'PostalLine6' => 'Varchar(200)',
        'Suburb' => 'Varchar(200)',
        'City' => 'Varchar(200)',
        'Postcode' => 'Varchar(200)',
        'Latitude' => 'Varchar(200)',
        'Longitude' => 'Varchar(200)'
    ];
}

To prefix these fields, call setFieldPrefix($prefix) on your AddressFinderField instance., (*10)

AddressFinderField::create('HomeAddress')
    ->setFieldPrefix('Home')
AddressFinderField::create('WorkAddress')
    ->setFieldPrefix('Work')

// requires the following model
private static $db = [
    'HomeAddress' => 'Text',
    'HomeAddressPostalLine1' => 'Varchar(200)',
    'HomeAddressPostalLine2' => 'Varchar(200)',
    'HomeAddressPostalLine3' => 'Varchar(200)',
    'HomeAddressPostalLine4' => 'Varchar(200)',
    'HomeAddressPostalLine5' => 'Varchar(200)',
    'HomeAddressPostalLine6' => 'Varchar(200)',
    'HomeAddressSuburb' => 'Varchar(200)',
    'HomeAddressCity' => 'Varchar(200)',
    'HomeAddressPostcode' => 'Varchar(200)',
    'HomeAddressLatitude' => 'Varchar(200)',
    'HomeAddressLongitude' => 'Varchar(200)',
    'WorkAddress' => 'Text',
    'WorkAddressPostalLine1' => 'Varchar(200)',
    'WorkAddressPostalLine2' => 'Varchar(200)',
    //...
];

The Versions

02/10 2017

dev-master

9999999-dev https://github.com/fullscreeninteractive/silverstripe-addressfinder

SilverStripe FormField for AddressFinder.co.nz

  Sources   Download

BSD-3-Clause

The Requires

 

form silverstripe

06/06 2017

1.1.0

1.1.0.0 https://github.com/fullscreeninteractive/silverstripe-addressfinder

SilverStripe FormField for AddressFinder.co.nz

  Sources   Download

BSD-3-Clause

The Requires

 

form silverstripe

08/05 2016

1.0.0

1.0.0.0 https://github.com/fullscreeninteractive/silverstripe-addressfinder

SilverStripe FormField for AddressFinder.co.nz

  Sources   Download

BSD-3-Clause

The Requires

 

form silverstripe