You are here

public function Date::getItemFormat in Webform 8.5

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

Get element's single value format name by looking for '#format' property, global settings, and finally default settings.

Parameters

array $element: An element.

Return value

string An element's format name.

Overrides WebformElementBase::getItemFormat

File

src/Plugin/WebformElement/Date.php, line 109

Class

Date
Provides a 'date' element.

Namespace

Drupal\webform\Plugin\WebformElement

Code

public function getItemFormat(array $element) {
  $format = parent::getItemFormat($element);

  // Drupal's default date fallback includes the time so we need to fallback
  // to the specified or default date only format.
  if ($format === 'fallback') {
    $format = isset($element['#date_date_format']) ? $element['#date_date_format'] : $this
      ->getDefaultProperty('date_date_format');
  }
  return $format;
}