You are here

public function WebformMarkupBase::prepare in Webform 8.5

Same name and namespace in other branches
  1. 6.x src/Plugin/WebformElement/WebformMarkupBase.php \Drupal\webform\Plugin\WebformElement\WebformMarkupBase::prepare()

Prepare an element to be rendered within a webform.

Parameters

array $element: An element.

\Drupal\webform\WebformSubmissionInterface $webform_submission: A webform submission. Webform submission is optional since it is not used by composite sub elements.

Overrides WebformDisplayOnTrait::prepare

See also

\Drupal\webform\Element\WebformCompositeBase::processWebformComposite

1 call to WebformMarkupBase::prepare()
WebformMessage::prepare in src/Plugin/WebformElement/WebformMessage.php
Prepare an element to be rendered within a webform.
1 method overrides WebformMarkupBase::prepare()
WebformMessage::prepare in src/Plugin/WebformElement/WebformMessage.php
Prepare an element to be rendered within a webform.

File

src/Plugin/WebformElement/WebformMarkupBase.php, line 58

Class

WebformMarkupBase
Provides a base 'markup' element.

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
    ->hasProperty('display_on') && !$this
    ->isDisplayOn($element, WebformElementDisplayOnInterface::DISPLAY_ON_FORM)) {
    $element['#access'] = FALSE;
  }

  // Add form element wrapper.
  if ($this
    ->hasProperty('wrapper_attributes')) {
    $element['#theme_wrappers'][] = 'form_element';
  }
}