public function WebformTelephone::form in Webform 6.x
Same name and namespace in other branches
- 8.5 src/Plugin/WebformElement/WebformTelephone.php \Drupal\webform\Plugin\WebformElement\WebformTelephone::form()
Gets the actual configuration webform array to be built.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
array An associative array contain the element's configuration webform without any default values.
Overrides WebformCompositeBase::form
File
- src/
Plugin/ WebformElement/ WebformTelephone.php, line 103
Class
- WebformTelephone
- Provides a 'telephone' (composite) element.
Namespace
Drupal\webform\Plugin\WebformElementCode
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',
'#description' => $this
->t('Enhance the telephone element\'s international support using the jQuery <a href=":href">International Telephone Input</a> plugin.', [
':href' => 'http://intl-tel-input.com/',
]),
'#return_value' => TRUE,
];
$form['composite']['phone__international_initial_country'] = [
'#title' => $this
->t('Initial country'),
'#type' => 'select',
'#empty_option' => $this
->t('- None -'),
'#options' => [
'auto' => $this
->t('Auto detect'),
] + CountryManager::getStandardList(),
'#states' => [
'visible' => [
':input[name="properties[phone__international]"]' => [
'checked' => TRUE,
],
],
],
];
if ($this->librariesManager
->isExcluded('jquery.intl-tel-input')) {
$form['composite']['phone__international']['#access'] = FALSE;
$form['composite']['phone__international_initial_country']['#access'] = FALSE;
}
return $form;
}