Commit 27d1c839 authored by finne's avatar finne Committed by bojanz
Browse files

Issue #2871741 by finne: zone_territory form element not working

parent d929db7c
zone_territory:
type: mapping
label: 'Zone territory'
mapping:
country_code:
type: string
label: 'Country'
administrative_area:
type: string
label: 'Administrative area'
locality:
type: string
label: 'Locality'
dependent_locality:
type: string
label: 'Dependent locality'
included_postal_codes:
type: string
label: 'Included postal codes'
excluded_postal_codes:
type: string
label: 'Excluded postal codes'
field.value.address:
type: mapping
label: 'Default value'
......
......@@ -3,14 +3,19 @@
namespace Drupal\address\Element;
use CommerceGuys\Addressing\AddressFormat\AddressFormat;
use CommerceGuys\Addressing\AddressFormat\AddressField;
use Drupal\address\FieldHelper;
use Drupal\address\LabelHelper;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Render\Element\FormElement;
use Drupal\Component\Utility\Html;
use Drupal\Component\Utility\NestedArray;
/**
* Provides a zone territory form element.
*
* Use it to populate a \CommerceGuys\Addressing\Zone\ZoneTerritory object.
*
* Usage example:
* @code
* $form['territory'] = [
......@@ -41,7 +46,6 @@ class ZoneTerritory extends FormElement {
[$class, 'processGroup'],
],
'#pre_render' => [
[$class, 'groupElements'],
[$class, 'preRenderGroup'],
],
'#after_build' => [
......@@ -180,7 +184,7 @@ class ZoneTerritory extends FormElement {
'#title' => $labels[$field],
'#options' => $subdivisions,
'#default_value' => $value[$property],
'#empty_option' => $this->t('- All -'),
'#empty_option' => t('- All -'),
];
if ($current_depth < $depth) {
$element[$property]['#ajax'] = [
......@@ -216,14 +220,14 @@ class ZoneTerritory extends FormElement {
$element['included_postal_codes'] = [
'#type' => 'textfield',
'#title' => $this->t('Included postal codes'),
'#description' => $this->t('A regular expression ("/(35|38)[0-9]{3}/") or comma-separated list, including ranges ("98, 100:200")'),
'#title' => t('Included postal codes'),
'#description' => t('A regular expression ("/(35|38)[0-9]{3}/") or comma-separated list, including ranges ("98, 100:200")'),
'#default_value' => $value['included_postal_codes'],
];
$element['excluded_postal_codes'] = [
'#type' => 'textfield',
'#title' => $this->t('Excluded postal codes'),
'#description' => $this->t('A regular expression ("/(35|38)[0-9]{3}/") or comma-separated list, including ranges ("98, 100:200")'),
'#title' => t('Excluded postal codes'),
'#description' => t('A regular expression ("/(35|38)[0-9]{3}/") or comma-separated list, including ranges ("98, 100:200")'),
'#default_value' => $value['excluded_postal_codes'],
];
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment