/** * {@inheritdoc} */ public function buildConfigurationForm(array $form, FormStateInterface $form_state) { $form = parent::buildConfigurationForm($form, $form_state); $values = $form_state->getUserInput(); if ($values) { $values += $this->defaultConfiguration(); } else { $values = $this->configuration; } $wrapper_id = Html::getUniqueId('zone-members-ajax-wrapper'); $form += ['#prefix' => '<div id="' . $wrapper_id . '">', '#suffix' => '</div>', '#after_build' => [[get_class($this), 'clearValues']], '#wrapper_id' => $wrapper_id]; $form['country_code'] = ['#type' => 'select', '#title' => $this->t('Country'), '#options' => $this->countryRepository->getList(), '#default_value' => $values['country_code'], '#limit_validation_errors' => [], '#required' => TRUE, '#ajax' => ['callback' => [get_class($this), 'ajaxRefresh'], 'wrapper' => $wrapper_id]]; if (!empty($values['country_code'])) { $address_format = $this->addressFormatRepository->get($values['country_code']); $form = $this->buildSubdivisionElements($form, $values, $address_format); $form = $this->buildPostalCodeElements($form, $values, $address_format); } return $form; }
/** * {@inheritdoc} */ public function buildConfigurationForm(array $form, FormStateInterface $form_state) { $form = parent::buildConfigurationForm($form, $form_state); $form['zone'] = ['#type' => 'entity_autocomplete', '#title' => $this->t('Zone'), '#default_value' => $this->zoneStorage->load($this->configuration['zone']), '#target_type' => 'zone', '#tags' => FALSE, '#required' => TRUE]; return $form; }
/** * {@inheritdoc} */ public function buildConfigurationForm(array $form, FormStateInterface $form_state) { $form = parent::buildConfigurationForm($form, $form_state); $form['zone'] = ['#type' => 'entity_autocomplete', '#title' => $this->t('Zone'), '#default_value' => $this->zoneStorage->load($this->configuration['zone']), '#target_type' => 'zone', '#tags' => FALSE, '#required' => TRUE, '#selection_settings' => ['skip_id' => $this->parentZone->id(), 'sort' => ['field' => 'name', 'direction' => 'ASC']]]; return $form; }