fieldMode

  • fieldMode has four options: SEARCH, POPULATE, COUNTRY and PRESERVE.  These options govern the behavior of the fields that are mapped to the control.  Using the OR operator “|” you can set multiple options per field.
Fieldmode Description
SEARCH  Used to attach the suggestions to this field so as a user types address suggestions will appear in a dropdown.
PRESERVE  Used to preserve fields from being overwritten with results coming back from selecting an address.
POPULATE  Used populate fields based on the returned address components.
COUNTRY  Used to populate a country dropdown with a list of countries that can be selected to validate from.

fieldMode Example

Field Mapping

var fields = [
                { element: "iCompany", field: "BusinessName", mode: so.fieldMode.PRESERVE },
                { element: "iAddress1", field: "Address1", mode: so.fieldMode.SEARCH | so.fieldMode.POPULATE },
                { element: "iAddress2", field: "Address2", mode: so.fieldMode.POPULATE },
                { element: "iAddress3", field: "Address3", mode: so.fieldMode.POPULATE },
                { element: "iAddress4", field: "Address4", mode: so.fieldMode.POPULATE },
                { element: "iAddress5", field: "Address5", mode: so.fieldMode.POPULATE },
                { element: "iUnits", field: "SubPremise", mode: so.fieldMode.POPULATE },
                { element: "iLocality", field: "Locality", mode: so.fieldMode.POPULATE },
                { element: "iAdminArea", field: "AdminArea", mode: so.fieldMode.POPULATE },
                { element: "iPostal", field: "PostalCode", mode: so.fieldMode.POPULATE },
                { element: "iCountry", field: "Country", mode: so.fieldMode.COUNTRY}
             ];    

Mapping

  • The HTML fields from your form can be mapped to anything in the underlying JSON object returned from the selection of an address.  In the case above, in the fieldMode Example, you see many of the more common mappings.  The element part is for the ID of the HTML tag on the form and the field part is for the field to map to in the selected address JSON response. Mode, as described above, governs the behavior of the fields that are mapped to the control.  This mapping is the first parameter in the Address control object.

Address Control Object

var DOTSGlobalAddressComplete = new so.Address(fields, options);