public static function TextBase::isDefaultInputMask in Webform 6.x
Same name and namespace in other branches
- 8.5 src/Plugin/WebformElement/TextBase.php \Drupal\webform\Plugin\WebformElement\TextBase::isDefaultInputMask()
Check if an element's value is the input mask's default value.
Parameters
array $element: An element.
string $value: A value.
Return value
bool TRUE if an element's value is the input mask's default value.
2 calls to TextBase::isDefaultInputMask()
- TextBase::validateInputMask in src/
Plugin/ WebformElement/ TextBase.php - Form API callback. Validate input mask and display required error message.
- WebformSubmissionConditionsValidator::validateFormElement in src/
WebformSubmissionConditionsValidator.php - Validate a form element.
File
- src/
Plugin/ WebformElement/ TextBase.php, line 278
Class
- TextBase
- Provides a base 'text' (field) class.
Namespace
Drupal\webform\Plugin\WebformElementCode
public static function isDefaultInputMask(array $element, $value) {
if (empty($element['#input_mask']) || $value === '') {
return FALSE;
}
$input_mask = $element['#input_mask'];
$input_masks = [
"'alias': 'currency'" => '$ 0.00',
"'alias': 'currency_negative'" => '-$ 0.00',
"'alias': 'currency_positive_negative'" => '$ 0.00',
];
return isset($input_masks[$input_mask]) && $input_masks[$input_mask] === $value ? TRUE : FALSE;
}