public static function LoqatePcaAddress::processAddress in Loqate 2.x
Same name and namespace in other branches
- 8 src/Element/LoqatePcaAddress.php \Drupal\loqate\Element\LoqatePcaAddress::processAddress()
Process the address fields.
File
- src/
Element/ LoqatePcaAddress.php, line 70
Class
- LoqatePcaAddress
- Provides a simple Loqate PCA address form element.
Namespace
Drupal\loqate\ElementCode
public static function processAddress(array &$element, FormStateInterface $form_state, array &$complete_form) {
// Ensure tree structure in output.
$element['#tree'] = TRUE;
$element[PcaAddressElement::LINE1] = [
'#type' => 'textfield',
'#title' => new TranslatableMarkup('Address Line 1'),
'#default_value' => $element['#default_value'][PcaAddressElement::LINE1] ?? NULL,
'#required' => TRUE,
];
$element[PcaAddressElement::LINE2] = [
'#type' => 'textfield',
'#title' => new TranslatableMarkup('Address Line 2'),
'#default_value' => $element['#default_value'][PcaAddressElement::LINE2] ?? NULL,
];
$element[PcaAddressElement::POSTAL_CODE] = [
'#type' => 'textfield',
'#title' => new TranslatableMarkup('ZIP/Postal Code'),
'#default_value' => $element['#default_value'][PcaAddressElement::POSTAL_CODE] ?? NULL,
'#required' => TRUE,
'#size' => 10,
];
$element[PcaAddressElement::LOCALITY] = [
'#type' => 'textfield',
'#title' => new TranslatableMarkup('City/Town'),
'#default_value' => $element['#default_value'][PcaAddressElement::LOCALITY] ?? NULL,
'#required' => TRUE,
'#size' => 30,
];
$element[PcaAddressElement::ADMINISTRATIVE_AREA] = [
'#type' => 'textfield',
'#title' => new TranslatableMarkup('State/Province'),
'#default_value' => $element['#default_value'][PcaAddressElement::ADMINISTRATIVE_AREA] ?? NULL,
'#size' => 30,
];
$element[PcaAddressElement::COUNTRY_CODE] = [
'#type' => 'textfield',
'#title' => new TranslatableMarkup('Country'),
'#default_value' => $element['#default_value'][PcaAddressElement::COUNTRY_CODE] ?? NULL,
];
return $element;
}