You are here

public static function Datetime::processAjaxForm in Drupal 10

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Datetime/Element/Datetime.php \Drupal\Core\Datetime\Element\Datetime::processAjaxForm()
  2. 9 core/lib/Drupal/Core/Datetime/Element/Datetime.php \Drupal\Core\Datetime\Element\Datetime::processAjaxForm()

Form element processing handler for the #ajax form property.

This method is useful for non-input elements that can be used in and outside the context of a form.

Parameters

array $element: An associative array containing the properties of the element.

\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.

Overrides RenderElement::processAjaxForm

See also

self::preRenderAjaxForm()

File

core/lib/Drupal/Core/Datetime/Element/Datetime.php, line 318

Class

Datetime
Provides a datetime element.

Namespace

Drupal\Core\Datetime\Element

Code

public static function processAjaxForm(&$element, FormStateInterface $form_state, &$complete_form) {
  $element = parent::processAjaxForm($element, $form_state, $complete_form);

  // Copy the #ajax settings to the child elements.
  if (isset($element['#ajax'])) {
    if (isset($element['date'])) {
      $element['date']['#ajax'] = $element['#ajax'];
    }
    if (isset($element['time'])) {
      $element['time']['#ajax'] = $element['#ajax'];
    }
  }
  return $element;
}