You are here

public static function WebformElementBase::hiddenElementAfterBuild in Webform 6.x

Same name and namespace in other branches
  1. 8.5 src/Plugin/WebformElementBase.php \Drupal\webform\Plugin\WebformElementBase::hiddenElementAfterBuild()

Webform element #after_build callback.

Wrap #element_validate so that we suppress element validation errors.

File

src/Plugin/WebformElementBase.php, line 844

Class

WebformElementBase
Provides a base class for a webform element.

Namespace

Drupal\webform\Plugin

Code

public static function hiddenElementAfterBuild(array $element, FormStateInterface $form_state) {
  if (!isset($element['#access']) || $element['#access']) {
    return $element;
  }

  // Disabled #required validation for hidden elements.
  $element['#required'] = FALSE;
  return WebformElementHelper::setElementValidate($element);
}