You are here

public function DateList::prepare in Webform 6.x

Same name and namespace in other branches
  1. 8.5 src/Plugin/WebformElement/DateList.php \Drupal\webform\Plugin\WebformElement\DateList::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 DateBase::prepare

See also

\Drupal\webform\Element\WebformCompositeBase::processWebformComposite

File

src/Plugin/WebformElement/DateList.php, line 54

Class

DateList
Provides a 'datelist' element.

Namespace

Drupal\webform\Plugin\WebformElement

Code

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

  // Remove month abbreviation.
  // @see \Drupal\Core\Datetime\Element\Datelist::processDatelist
  if (isset($element['#date_abbreviate']) && $element['#date_abbreviate'] === FALSE) {
    $element['#date_date_callbacks'][] = '_webform_datelist_date_date_callback';
  }

  // Remove 'for' from the element's label.
  $element['#label_attributes']['webform-remove-for-attribute'] = TRUE;
  $element['#attached']['library'][] = 'webform/webform.element.datelist';
}