jFormer DocumentationAdvanced Fields

Address

JFormComponentAddress(String id, String label[, Array optionArray])

The Address field allows for both United States and international addresses. Fields within the Address component include two street address lines, city or region, state or province, zip or postal code, and country.

Usage

Constructor

	new JFormComponentAddress(String id, String label[, Array optionArray])
    

Sample Usage

Create an address component localized for United States:

	$address = new JFormComponentAddress('id', 'Label:', array(
		'unitedStatesOnly' => true
	));
    

Value Returned

Object

Keys: { addressLine1, addressLine2, city, state, zip, country }

CSS Class

.jFormComponentAddress

Options

false

unitedStatesOnly

boolean | Sets the component to format as a united states address, removes the country drop down, and replaces the text entry for 'state / province' with a drop down containing a list of States.

null

selectedCountry

string | Receives a string that is the two character country abbreviation for the desired default option

				'selectedCountry' => 'UG' // Uganda
        

null

selectedState

string | Sets the 'state' field to given value, Receives the two character state abbreviation as a string value. only works while 'unitedStatesOnly' is set to true.

			'selectedState' => 'CA' // California
        

true

showSubLabels

boolean | When set to false, hides input fields sublabels. This option is best used when emptyValues are set to true to provent redundancy.

false

emptyValues

boolean | when set to true, places an empty value in each of the text input fields so that the labels are shown inline.

			'emptyValues' => true
        

false

addressLine2Hidden

boolean | hides the second address line. This is good when you want your address component to be smaller, and only need basic address info.

			'addressLine2Hidden' => true,
        

null

initialValue

Array [addressLine1, addressLine2, city, state, zip, country] | Receives an associative array instead of a string, any or all of these fields can be left blank..

Component Options

These options are common to all components.

null

description

HTML | a description for the component, shows underneath the component inside a DIV with the class jFormComponenpescription.

null

instanceOptions

Array, [max(int), addButtonText(string), removeButtonText(text)] | see instanceOptions page for more information.

null

dependencyOptions

Array, [dependentOn(string), display(string), jsFunction(Javascript)[, animationOptions(array)]] | see dependencyOptions page for more information.

null

triggerFunction

Javascript | a javascript function that runs upon component change.

null

tip

HTML | a tooltip that displays whenever the component has focus. Gives any extra help or explanation a form user might need.

null

validationOptions

Array | an of validations specific to the component, see the specific component for its validations.

false

showErrorTipOnce

Boolean | this option makes the error tip only show up on the first focus on the component if it does not pass validation.

false

enterSubmits

Boolean | if true pressing enter while this component has focus submits the form, or advances to the next page.

null

style

CSS | set the style attribute for the component wrapper div.

null

initialValue

String | preset the value of the component upon form loading.

Address Validation Options

NameError Message and Description
required

Will tell you which field or fields are empty

"[missing field] is Required."

Makes the component required, all lines of the address field must be filled out, except for addressLine2 if it is shown.

Next Page: Date

This page was last edited on April 25, 2011 at 11:05am.

4 comments (add a comment)

Frank on 2012-02-07 08:41:50

How do you use the initial value for the address? I've tried using an array but I don't think I'm constructing it well.

Please help. Thx!

robert on 2012-03-20 09:05:47

The initial values does not seem to work....Is there a working example? I've tried things like this but with no luck.

'initialValues' => array ('addressLine1' => $_GET['ccaddress1'] , 'addressLine2' => $_GET['ccaddress2'] , 'city' => $_GET['cccity'],
'state' => $_GET['ccstate'], 'zip' => $_GET['cczip']),

Thx
R

brian on 2012-03-21 12:25:25

to get initial values to work for the address component you need to modify the jformer.php source...If you read through it the address component source it does not actually accept initial values..

Martijn on 2012-04-27 04:55:45

Please notice that the zip/postal code has a maxlength of 5, and therefor may be insufficient for other countries (ea. Netherlands zip code = 1234 AB)