protected function OptionsLimitWebformHandler::disableOptionsElement 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::disableOptionsElement()
Disable options element's reached options.
Parameters
array $element: An options element with limits.
array $reached: An options element's reached options.
1 call to OptionsLimitWebformHandler::disableOptionsElement()
- OptionsLimitWebformHandler::alterOptionsElement in modules/
webform_options_limit/ src/ Plugin/ WebformHandler/ OptionsLimitWebformHandler.php - Alter an options element.
File
- modules/
webform_options_limit/ src/ Plugin/ WebformHandler/ OptionsLimitWebformHandler.php, line 713
Class
- OptionsLimitWebformHandler
- Webform options and boolean (boolean) limit handler.
Namespace
Drupal\webform_options_limit\Plugin\WebformHandlerCode
protected function disableOptionsElement(array &$element, array $reached) {
$webform_element = $this
->getWebformElement();
if ($this
->isTableSelectElement()) {
// Hide disabled table select checkbox or radio.
foreach ($reached as $reached_option) {
$element[$reached_option]['#access'] = FALSE;
}
}
elseif ($webform_element
->hasProperty('options__properties')) {
// Set element options disabled properties.
foreach ($reached as $reached_option) {
$element['#options__properties'][$reached_option] = [
'#disabled' => TRUE,
];
}
}
else {
// Set select menu disabled attribute.
// @see Drupal.behaviors.webformSelectOptionsDisabled
// @see webform.element.select.js
$element['#attributes']['data-webform-select-options-disabled'] = implode(',', $reached);
}
}