51 parent::__construct(
$name, $parameters,
$form);
61 $this->propsMaxLength = [
70 if (isset($parameters[
'props'])) {
71 $this->props = $parameters[
'props'];
73 foreach ($this->props as $prop) {
74 if (isset($parameters[
"default$prop"])) {
75 $this->defaults[
"default$prop"] = $parameters[
"default$prop"];
79 $this->defaults[
'priorityCountries'] = isset($parameters[
'priorityCountries'])
80 ? $parameters[
'priorityCountries']
83 $this->prefix = isset($parameters[
'prefix'])
84 ? rtrim($parameters[
'prefix'],
'_') .
'_'
99 parent::setDefaults();
101 $this->defaults[
'required'] =
false;
102 $this->defaults[
'labelAddress1'] = _(
"Address 1");
103 $this->defaults[
'labelAddress2'] = _(
"Address 2");
104 $this->defaults[
'labelCity'] = _(
"City");
105 $this->defaults[
'labelState'] = _(
"State");
106 $this->defaults[
'labelZip'] = _(
"Zip");
107 $this->defaults[
'labelCountry'] = _(
"Country");
117 parent::addChildElements();
119 foreach ($this->props as $prop) {
120 if (isset($this->defaults[
"default$prop"])) {
121 $labelVar =
"label$prop";
123 if ($prop ==
"State") {
124 $this->addState($this->prefix .
"state", array(
125 'label' => $this->labelState,
126 'defaultValue' => $this->defaults[
'defaultState'],
129 }
else if ($prop ==
"Country") {
130 $this->addCountry($this->prefix .
"country", array(
131 'label' => $this->labelCountry,
132 'priorityCountries' => $this->defaults[
'priorityCountries'],
133 'defaultValue' => $this->defaults[
'defaultCountry'],
134 'required' => $this->required,
137 $this->addText($this->prefix . strtolower($prop), array(
138 'label' => $this->$labelVar,
139 'maxlength' => $this->propsMaxLength[$prop],
140 'defaultValue' => $this->defaults[
"default$prop"],
141 'required' => $prop !=
"Address2" && $this->required,
155 if (parent::validate() && isset($this->defaultCountry) && isset($this->defaultState)) {
157 $country_states = state::getStates();
158 $country = $this->
getElement(
"{$this->prefix}country");
159 $state = $this->
getElement(
"{$this->prefix}state");
160 $this->valid = isset($country_states[$country->getValue()][$state->getValue()]);
162 $state->errorMessage = _(
"State and Country do not match");
163 $state->valid =
false;
getElement($name, $includeFieldsets=false)
Gets subelement by name.
$valid
Contains element validation status/result.
Default address fieldset.
addChildElements()
adds address-inputs to fieldset
validate()
Validate the address data.
__construct($name, $parameters, $form)
multiple class constructor
setDefaults()
collects initial values across subclasses.
The fieldset class holds HTML-fieldset specific attributes and methods.
Classes for HTML input-elements.