public function MobileNumber::form in Mobile Number 8
Same name and namespace in other branches
- 2.0.x src/Plugin/WebformElement/MobileNumber.php \Drupal\mobile_number\Plugin\WebformElement\MobileNumber::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 WebformElementBase::form
File
- src/
Plugin/ WebformElement/ MobileNumber.php, line 41
Class
- MobileNumber
- Provides a 'mobile_number' element.
Namespace
Drupal\mobile_number\Plugin\WebformElementCode
public function form(array $form, FormStateInterface $form_state) {
$form = parent::form($form, $form_state);
/** @var \Drupal\mobile_number\MobileNumberUtilInterface $util */
$util = \Drupal::service('mobile_number.util');
$form['mobile_number'] = [
'#type' => 'fieldset',
'#title' => $this
->t('Mobile Number Settings'),
];
$form['mobile_number']['default_country'] = [
'#type' => 'select',
'#title' => t('Default Country'),
'#options' => $util
->getCountryOptions([], TRUE),
'#description' => t('Default country for mobile number input.'),
'#required' => TRUE,
'#element_validate' => [
[
$this,
'settingsFormValidate',
],
],
];
$form['mobile_number']['countries'] = [
'#type' => 'select',
'#title' => t('Allowed Countries'),
'#options' => $util
->getCountryOptions([], TRUE),
'#description' => t('Allowed countries for the mobile number. If none selected, then all are allowed.'),
'#multiple' => TRUE,
'#attached' => [
'library' => [
'mobile_number/element',
],
],
];
$form['mobile_number']['mn_placeholder'] = [
'#type' => 'textfield',
'#title' => t('Number Placeholder'),
'#description' => t('Number field placeholder.'),
];
$form['display']['as_link'] = [
'#type' => 'checkbox',
'#title' => t('Show as TEL link'),
];
return $form;
}