You are here

public static function DatexDate::preRenderDate in Datex 8

Adds form-specific attributes to a 'date' #type element.

Supports HTML5 types of 'date', 'datetime', 'datetime-local', and 'time'. Falls back to a plain textfield with JS datepicker support. Used as a sub-element by the datetime element type.

Parameters

array $element: An associative array containing the properties of the element. Properties used: #title, #value, #options, #description, #required, #attributes, #id, #name, #type, #min, #max, #step, #value, #size. The #name property will be sanitized before output. This is currently done by initializing Drupal\Core\Template\Attribute with all the attributes.

Return value

array The $element with prepared variables ready for #theme 'input__date'.

Overrides Date::preRenderDate

File

src/Element/DatexDate.php, line 17

Class

DatexDate
Plugin annotation @FormElement("date");

Namespace

Drupal\datex\Element

Code

public static function preRenderDate($element) {
  $element = parent::preRenderDate($element);
  if ($element['#attributes']['type'] === 'date') {
    $element['#attributes']['type'] = 'text';
  }
  return $element;
}