function Date::processDate

Same name and namespace in other branches
  1. 8.9.x core/lib/Drupal/Core/Render/Element/Date.php \Drupal\Core\Render\Element\Date::processDate()

Processes a date form element.

Parameters

array $element: The form element to process. Properties used:

  • #attributes: An associative array containing:

    • type: The type of date field rendered.
  • #date_date_format: The date format used in PHP formats.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

array $complete_form: The complete form structure.

Return value

array The processed element.

Deprecated

in drupal:9.4.0 and is removed from drupal:10.0.0. There is no replacement.

See also

https://www.drupal.org/node/3258267

1 call to Date::processDate()
DateElementTest::testProcessDate in core/tests/Drupal/Tests/Core/Render/Element/DateElementTest.php
@covers ::processDate @group legacy

File

core/lib/Drupal/Core/Render/Element/Date.php, line 67

Class

Date
Provides a form element for date selection.

Namespace

Drupal\Core\Render\Element

Code

public static function processDate(&$element, FormStateInterface $form_state, &$complete_form) {
    @trigger_error('Drupal\\Core\\Render\\Element\\Date::processDate() is deprecated in drupal:9.4.0 and is removed from drupal:10.0.0. There is no replacement. See https://www.drupal.org/node/3258267', E_USER_DEPRECATED);
    // Attach JS support for the date field, if we can determine which date
    // format should be used.
    if ($element['#attributes']['type'] == 'date' && !empty($element['#date_date_format'])) {
        $element['#attached']['library'][] = 'core/drupal.date';
        $element['#attributes']['data-drupal-date-format'] = [
            $element['#date_date_format'],
        ];
    }
    return $element;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.