public function MobileNumber::setDefaultValue 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::setDefaultValue()
Set an element's default value using saved data.
The method allows the submission's 'saved' #default_value to be different from the element's #default_value.
Parameters
array $element: An element.
Overrides WebformElementBase::setDefaultValue
See also
\Drupal\webform\Plugin\WebformElement\DateBase::setDefaultValue
\Drupal\webform\Plugin\WebformElement\EntityAutocomplete::setDefaultValue
File
- src/
Plugin/ WebformElement/ MobileNumber.php, line 104
Class
- MobileNumber
- Provides a 'mobile_number' element.
Namespace
Drupal\mobile_number\Plugin\WebformElementCode
public function setDefaultValue(array &$element) {
parent::setDefaultValue($element);
$settings = [
'default_country' => !empty($element['#default_country']) ? $element['#default_country'] : 'US',
];
$element += [
'#default_value' => [
'country' => $settings['default_country'],
],
];
}