Loading includes/webform.options.inc +6 −2 Original line number Diff line number Diff line Loading @@ -46,7 +46,9 @@ function webform_webform_options_time_zones_alter(array &$options, array $elemen */ function webform_webform_options_country_codes_alter(array &$options, array $element = []) { if (empty($options)) { $options = CountryManager::getStandardList(); /** @var \Drupal\Core\Locale\CountryManagerInterface $country_manager */ $country_manager = \Drupal::service('country_manager'); $options = $country_manager->getList(); } } Loading @@ -55,7 +57,9 @@ function webform_webform_options_country_codes_alter(array &$options, array $ele */ function webform_webform_options_country_names_alter(array &$options, array $element = []) { if (empty($options)) { $countries = CountryManager::getStandardList(); /** @var \Drupal\Core\Locale\CountryManagerInterface $country_manager */ $country_manager = \Drupal::service('country_manager'); $countries = $country_manager->getList(); $options = array_combine($countries, $countries); } } Loading src/Plugin/WebformElement/Telephone.php +10 −3 Original line number Diff line number Diff line Loading @@ -5,7 +5,6 @@ namespace Drupal\webform\Plugin\WebformElement; use Drupal\Component\Serialization\Json; use Drupal\webform\Element\WebformMessage as WebformMessageElement; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Locale\CountryManager; use Drupal\webform\WebformInterface; use Drupal\webform\WebformSubmissionInterface; use Symfony\Component\DependencyInjection\ContainerInterface; Loading Loading @@ -38,6 +37,13 @@ class Telephone extends TextBase { */ protected $telephoneValidator; /** * The country manager. * * @var \Drupal\Core\Locale\CountryManagerInterface */ protected $countryManager; /** * {@inheritdoc} */ Loading @@ -47,6 +53,7 @@ class Telephone extends TextBase { $instance->telephoneValidator = ($instance->moduleHandler->moduleExists('telephone_validation')) ? $container->get('telephone_validation.validator') : NULL; $instance->countryManager = $container->get('country_manager'); return $instance; } Loading Loading @@ -159,7 +166,7 @@ class Telephone extends TextBase { '#title' => $this->t('Initial country'), '#type' => 'select', '#empty_option' => $this->t('- None -'), '#options' => CountryManager::getStandardList(), '#options' => $this->countryManager->getList(), '#states' => [ 'visible' => [':input[name="properties[international]"]' => ['checked' => TRUE]], ], Loading @@ -167,7 +174,7 @@ class Telephone extends TextBase { $form['telephone']['international_preferred_countries'] = [ '#title' => $this->t('Preferred countries'), '#type' => 'select', '#options' => CountryManager::getStandardList(), '#options' => $this->countryManager->getList(), '#description' => $this->t('Specify the countries to appear at the top of the list.'), '#select2' => TRUE, '#multiple' => TRUE, Loading src/Plugin/WebformElement/WebformTelephone.php +19 −1 Original line number Diff line number Diff line Loading @@ -5,6 +5,7 @@ namespace Drupal\webform\Plugin\WebformElement; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Locale\CountryManager; use Drupal\webform\WebformSubmissionInterface; use Symfony\Component\DependencyInjection\ContainerInterface; /** * Provides a 'telephone' (composite) element. Loading @@ -20,6 +21,22 @@ use Drupal\webform\WebformSubmissionInterface; */ class WebformTelephone extends WebformCompositeBase { /** * The country manager. * * @var \Drupal\Core\Locale\CountryManagerInterface */ protected $countryManager; /** * {@inheritdoc} */ public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { $instance = parent::create($container, $configuration, $plugin_id, $plugin_definition); $instance->countryManager = $container->get('country_manager'); return $instance; } /** * {@inheritdoc} */ Loading Loading @@ -102,6 +119,7 @@ class WebformTelephone extends WebformCompositeBase { */ public function form(array $form, FormStateInterface $form_state) { $form = parent::form($form, $form_state); $form['composite']['phone__international'] = [ '#title' => $this->t('Enhance support for international phone numbers'), '#type' => 'checkbox', Loading @@ -114,7 +132,7 @@ class WebformTelephone extends WebformCompositeBase { '#empty_option' => $this->t('- None -'), '#options' => [ 'auto' => $this->t('Auto detect'), ] + CountryManager::getStandardList(), ] + $this->countryManager->getList(), '#states' => [ 'visible' => [ ':input[name="properties[phone__international]"]' => ['checked' => TRUE], Loading Loading
includes/webform.options.inc +6 −2 Original line number Diff line number Diff line Loading @@ -46,7 +46,9 @@ function webform_webform_options_time_zones_alter(array &$options, array $elemen */ function webform_webform_options_country_codes_alter(array &$options, array $element = []) { if (empty($options)) { $options = CountryManager::getStandardList(); /** @var \Drupal\Core\Locale\CountryManagerInterface $country_manager */ $country_manager = \Drupal::service('country_manager'); $options = $country_manager->getList(); } } Loading @@ -55,7 +57,9 @@ function webform_webform_options_country_codes_alter(array &$options, array $ele */ function webform_webform_options_country_names_alter(array &$options, array $element = []) { if (empty($options)) { $countries = CountryManager::getStandardList(); /** @var \Drupal\Core\Locale\CountryManagerInterface $country_manager */ $country_manager = \Drupal::service('country_manager'); $countries = $country_manager->getList(); $options = array_combine($countries, $countries); } } Loading
src/Plugin/WebformElement/Telephone.php +10 −3 Original line number Diff line number Diff line Loading @@ -5,7 +5,6 @@ namespace Drupal\webform\Plugin\WebformElement; use Drupal\Component\Serialization\Json; use Drupal\webform\Element\WebformMessage as WebformMessageElement; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Locale\CountryManager; use Drupal\webform\WebformInterface; use Drupal\webform\WebformSubmissionInterface; use Symfony\Component\DependencyInjection\ContainerInterface; Loading Loading @@ -38,6 +37,13 @@ class Telephone extends TextBase { */ protected $telephoneValidator; /** * The country manager. * * @var \Drupal\Core\Locale\CountryManagerInterface */ protected $countryManager; /** * {@inheritdoc} */ Loading @@ -47,6 +53,7 @@ class Telephone extends TextBase { $instance->telephoneValidator = ($instance->moduleHandler->moduleExists('telephone_validation')) ? $container->get('telephone_validation.validator') : NULL; $instance->countryManager = $container->get('country_manager'); return $instance; } Loading Loading @@ -159,7 +166,7 @@ class Telephone extends TextBase { '#title' => $this->t('Initial country'), '#type' => 'select', '#empty_option' => $this->t('- None -'), '#options' => CountryManager::getStandardList(), '#options' => $this->countryManager->getList(), '#states' => [ 'visible' => [':input[name="properties[international]"]' => ['checked' => TRUE]], ], Loading @@ -167,7 +174,7 @@ class Telephone extends TextBase { $form['telephone']['international_preferred_countries'] = [ '#title' => $this->t('Preferred countries'), '#type' => 'select', '#options' => CountryManager::getStandardList(), '#options' => $this->countryManager->getList(), '#description' => $this->t('Specify the countries to appear at the top of the list.'), '#select2' => TRUE, '#multiple' => TRUE, Loading
src/Plugin/WebformElement/WebformTelephone.php +19 −1 Original line number Diff line number Diff line Loading @@ -5,6 +5,7 @@ namespace Drupal\webform\Plugin\WebformElement; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Locale\CountryManager; use Drupal\webform\WebformSubmissionInterface; use Symfony\Component\DependencyInjection\ContainerInterface; /** * Provides a 'telephone' (composite) element. Loading @@ -20,6 +21,22 @@ use Drupal\webform\WebformSubmissionInterface; */ class WebformTelephone extends WebformCompositeBase { /** * The country manager. * * @var \Drupal\Core\Locale\CountryManagerInterface */ protected $countryManager; /** * {@inheritdoc} */ public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { $instance = parent::create($container, $configuration, $plugin_id, $plugin_definition); $instance->countryManager = $container->get('country_manager'); return $instance; } /** * {@inheritdoc} */ Loading Loading @@ -102,6 +119,7 @@ class WebformTelephone extends WebformCompositeBase { */ public function form(array $form, FormStateInterface $form_state) { $form = parent::form($form, $form_state); $form['composite']['phone__international'] = [ '#title' => $this->t('Enhance support for international phone numbers'), '#type' => 'checkbox', Loading @@ -114,7 +132,7 @@ class WebformTelephone extends WebformCompositeBase { '#empty_option' => $this->t('- None -'), '#options' => [ 'auto' => $this->t('Auto detect'), ] + CountryManager::getStandardList(), ] + $this->countryManager->getList(), '#states' => [ 'visible' => [ ':input[name="properties[phone__international]"]' => ['checked' => TRUE], Loading