/**
  * {@inheritdoc}
  */
 public function form(array $form, FormStateInterface $form_state)
 {
     $form = parent::form($form, $form_state);
     $address_format = $this->entity;
     $country_code = $address_format->getCountryCode();
     if ($country_code == 'ZZ') {
         $form['countryCode'] = ['#type' => 'item', '#title' => $this->t('Country'), '#markup' => $this->t('Generic')];
     } else {
         $form['countryCode'] = ['#type' => 'select', '#title' => $this->t('Country'), '#default_value' => $country_code, '#required' => TRUE, '#options' => $this->countryRepository->getList(), '#disabled' => !$address_format->isNew()];
     }
     $form['format'] = ['#type' => 'textarea', '#title' => $this->t('Format'), '#description' => $this->t('Available tokens: @tokens', ['@tokens' => implode(', ', AddressField::getTokens())]), '#default_value' => $address_format->getFormat(), '#required' => TRUE];
     $form['requiredFields'] = ['#type' => 'checkboxes', '#title' => t('Required fields'), '#options' => LabelHelper::getGenericFieldLabels(), '#default_value' => $address_format->getRequiredFields()];
     $form['uppercaseFields'] = ['#type' => 'checkboxes', '#title' => t('Uppercase fields'), '#description' => t('Uppercased on envelopes to facilitate automatic post handling.'), '#options' => LabelHelper::getGenericFieldLabels(), '#default_value' => $address_format->getUppercaseFields()];
     $form['postalCodePattern'] = ['#type' => 'textfield', '#title' => $this->t('Postal code pattern'), '#description' => $this->t('Regular expression used to validate postal codes.'), '#default_value' => $address_format->getPostalCodePattern()];
     $form['postalCodePrefix'] = ['#type' => 'textfield', '#title' => $this->t('Postal code prefix'), '#description' => $this->t('Added to postal codes when formatting an address for international mailing.'), '#default_value' => $address_format->getPostalCodePrefix(), '#size' => 5];
     $form['postalCodeType'] = ['#type' => 'select', '#title' => $this->t('Postal code type'), '#default_value' => $address_format->getPostalCodeType(), '#options' => LabelHelper::getPostalCodeLabels(), '#empty_value' => ''];
     $form['dependentLocalityType'] = ['#type' => 'select', '#title' => $this->t('Dependent locality type'), '#default_value' => $address_format->getDependentLocalityType(), '#options' => LabelHelper::getDependentLocalityLabels(), '#empty_value' => ''];
     $form['localityType'] = ['#type' => 'select', '#title' => $this->t('Locality type'), '#default_value' => $address_format->getLocalityType(), '#options' => LabelHelper::getLocalityLabels(), '#empty_value' => ''];
     $form['administrativeAreaType'] = ['#type' => 'select', '#title' => $this->t('Administrative area type'), '#default_value' => $address_format->getAdministrativeAreaType(), '#options' => LabelHelper::getAdministrativeAreaLabels(), '#empty_value' => ''];
     return $form;
 }