You are here

public function WebformDisplayOnTrait::prepare in Webform 6.x

Same name and namespace in other branches
  1. 8.5 src/Plugin/WebformElement/WebformDisplayOnTrait.php \Drupal\webform\Plugin\WebformElement\WebformDisplayOnTrait::prepare()
4 methods override WebformDisplayOnTrait::prepare()
WebformComputedBase::prepare in src/Plugin/WebformElement/WebformComputedBase.php
Prepare an element to be rendered within a webform.
WebformHorizontalRule::prepare in src/Plugin/WebformElement/WebformHorizontalRule.php
Prepare an element to be rendered within a webform.
WebformMarkupBase::prepare in src/Plugin/WebformElement/WebformMarkupBase.php
Prepare an element to be rendered within a webform.
WebformVariant::prepare in src/Plugin/WebformElement/WebformVariant.php
Prepare an element to be rendered within a webform.

File

src/Plugin/WebformElement/WebformDisplayOnTrait.php, line 16

Class

WebformDisplayOnTrait
Provides an 'display_on' trait.

Namespace

Drupal\webform\Plugin\WebformElement

Code

public function prepare(array &$element, WebformSubmissionInterface $webform_submission = NULL) {
  parent::prepare($element, $webform_submission);

  // Hide element if it should not be displayed on 'form'.
  if (!$this
    ->isDisplayOn($element, WebformElementDisplayOnInterface::DISPLAY_ON_FORM)) {
    $element['#access'] = FALSE;
  }
}