You are here

public static function WebformElementBase::hiddenElementAfterBuild in Webform 8.5

Same name and namespace in other branches
  1. 6.x 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 916

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);
}