public static function WebformExcludedBase::validateWebformExcluded in Webform 6.x
Same name and namespace in other branches
- 8.5 src/Element/WebformExcludedBase.php \Drupal\webform\Element\WebformExcludedBase::validateWebformExcluded()
Validates a tablelselect element.
File
- src/
Element/ WebformExcludedBase.php, line 77
Class
- WebformExcludedBase
- Provides a base webform element for webform excluded elements and columns.
Namespace
Drupal\webform\ElementCode
public static function validateWebformExcluded(array &$element, FormStateInterface $form_state, &$complete_form) {
$value = array_filter($element['tableselect']['#value']);
// Converted value to excluded elements.
$options = array_keys($element['tableselect']['#options']);
$excluded = array_diff($options, $value);
// Unset tableselect and set the element's value to excluded.
$form_state
->setValueForElement($element['tableselect'], NULL);
$value = array_combine($excluded, $excluded);
$element['#value'] = $value;
$form_state
->setValueForElement($element, $value);
}