You are here

protected function WebformSubmissionConditionsValidator::addStatesHiddenToElement in Webform 8.5

Same name and namespace in other branches
  1. 6.x src/WebformSubmissionConditionsValidator.php \Drupal\webform\WebformSubmissionConditionsValidator::addStatesHiddenToElement()

Add .js-webform-states-hidden to an element.

Parameters

array $element: An element.

1 call to WebformSubmissionConditionsValidator::addStatesHiddenToElement()
WebformSubmissionConditionsValidator::buildForm in src/WebformSubmissionConditionsValidator.php
Apply form #states to visible elements.

File

src/WebformSubmissionConditionsValidator.php, line 1089

Class

WebformSubmissionConditionsValidator
Webform submission conditions (#states) validator.

Namespace

Drupal\webform

Code

protected function addStatesHiddenToElement(array &$element) {
  $element_plugin = $this->elementManager
    ->getElementInstance($element);
  $attributes_property = $element_plugin
    ->hasWrapper($element) || $element_plugin
    ->getPluginDefinition()['states_wrapper'] ? '#wrapper_attributes' : '#attributes';
  $element += [
    $attributes_property => [],
  ];
  $element[$attributes_property] += [
    'class' => [],
  ];
  $element[$attributes_property]['class'][] = 'js-webform-states-hidden';
}