protected function OptionsLimitWebformHandler::setBooleanElementDefaultValue in Webform 8.5
Same name and namespace in other branches
- 6.x modules/webform_options_limit/src/Plugin/WebformHandler/OptionsLimitWebformHandler.php \Drupal\webform_options_limit\Plugin\WebformHandler\OptionsLimitWebformHandler::setBooleanElementDefaultValue()
Set a boolean element's default value.
Parameters
array $element: A boolean element with limits.
array $limit: A boolean element's limit information.
string $operation: The form's current operation.
1 call to OptionsLimitWebformHandler::setBooleanElementDefaultValue()
- OptionsLimitWebformHandler::alterElement in modules/
webform_options_limit/ src/ Plugin/ WebformHandler/ OptionsLimitWebformHandler.php - Alter webform element.
File
- modules/
webform_options_limit/ src/ Plugin/ WebformHandler/ OptionsLimitWebformHandler.php, line 827
Class
- OptionsLimitWebformHandler
- Webform options and boolean (boolean) limit handler.
Namespace
Drupal\webform_options_limit\Plugin\WebformHandlerCode
protected function setBooleanElementDefaultValue(array &$element, array $limit, $operation) {
if ($operation === 'test') {
if ($limit['status'] === WebformOptionsLimitHandlerInterface::LIMIT_STATUS_NONE) {
unset($element['#default_value']);
}
}
else {
$element_key = $this->configuration['element_key'];
$webform_submission = $this
->getWebformSubmission();
$original_value = $webform_submission
->getElementOriginalData($element_key);
if ($limit['status'] === WebformOptionsLimitHandlerInterface::LIMIT_STATUS_NONE && !$original_value) {
unset($element['#default_value']);
}
}
}