jFormer Documentation → Advanced Fields →
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.
new JFormComponentAddress(String id, String label[, Array optionArray])
Create an address component localized for United States:
$address = new JFormComponentAddress('id', 'Label:', array(
'unitedStatesOnly' => true
));
Object
Keys: { addressLine1, addressLine2, city, state, zip, country }
.jFormComponentAddress
false
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
string | Receives a string that is the two character country abbreviation for the desired default option
'selectedCountry' => 'UG' // Uganda
null
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
boolean | When set to false, hides input fields sublabels. This option is best used when emptyValues are set to true to provent redundancy.
false
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
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
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..
These options are common to all components.
null
HTML | a description for the component, shows underneath the component inside a DIV with the class jFormComponenpescription.
null
Array, [max(int), addButtonText(string), removeButtonText(text)] | see instanceOptions page for more information.
null
Array, [dependentOn(string), display(string), jsFunction(Javascript)[, animationOptions(array)]] | see dependencyOptions page for more information.
null
HTML | a tooltip that displays whenever the component has focus. Gives any extra help or explanation a form user might need.
null
Array | an of validations specific to the component, see the specific component for its validations.
false
Boolean | this option makes the error tip only show up on the first focus on the component if it does not pass validation.
false
Boolean | if true pressing enter while this component has focus submits the form, or advances to the next page.
null
CSS | set the style attribute for the component wrapper div.
null
String | preset the value of the component upon form loading.
| Name | Error 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)
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!
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
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)