function Datelist::checkEmptyInputs

Same name in other branches
  1. 8.9.x core/lib/Drupal/Core/Datetime/Element/Datelist.php \Drupal\Core\Datetime\Element\Datelist::checkEmptyInputs()
  2. 10 core/lib/Drupal/Core/Datetime/Element/Datelist.php \Drupal\Core\Datetime\Element\Datelist::checkEmptyInputs()
  3. 11.x core/lib/Drupal/Core/Datetime/Element/Datelist.php \Drupal\Core\Datetime\Element\Datelist::checkEmptyInputs()

Checks the input array for empty values.

Input array keys are checked against values in the parts array. Elements not in the parts array are ignored. Returns an array representing elements from the input array that have no value. If no empty values are found, returned array is empty.

Parameters

array $input: Array of individual inputs to check for value.

array $parts: Array to check input against, ignoring elements not in this array.

Return value

array Array of keys from the input array that have no value, may be empty.

2 calls to Datelist::checkEmptyInputs()
Datelist::validateDatelist in core/lib/Drupal/Core/Datetime/Element/Datelist.php
Validation callback for a datelist element.
Datelist::valueCallback in core/lib/Drupal/Core/Datetime/Element/Datelist.php
Validates the date type to adjust 12 hour time and prevent invalid dates. If the date is valid, the date is set in the form.

File

core/lib/Drupal/Core/Datetime/Element/Datelist.php, line 345

Class

Datelist
Provides a datelist element.

Namespace

Drupal\Core\Datetime\Element

Code

protected static function checkEmptyInputs($input, $parts) {
    // The object key does not represent an input value, see
    // \Drupal\Core\Datetime\Element\Datelist::valueCallback().
    unset($input['object']);
    // Filters out empty array values, any valid value would have a string length.
    $filtered_input = array_filter($input, 'strlen');
    return array_diff($parts, array_keys($filtered_input));
}

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