1 date.elements.inc _date_html5_get_attributes(array $date_limits, array $granularity)

Helper function to construct form item attributes.

Takes care of nested (html_datetime) and unnested (html_date) form items.

Parameters

array $date_limits: Array keyed by min/max.

array $granularity: Field's date granularity settings.

Return value

array:

File

core/modules/date/date.elements.inc, line 2196
Date forms and form themes and validation.

Code

function _date_html5_get_attributes(array $date_limits, array $granularity) {
  $attributes = array();
  $has_time = !empty($granularity['hour']);

  if (!empty($date_limits['min'])) {
    if ($has_time) {
      $attributes['date']['min'] = $date_limits['min'];
    }
    else {
      $attributes['min'] = $date_limits['min'];
    }
  }

  if (!empty($date_limits['max'])) {
    if ($has_time) {
      $attributes['date']['max'] = $date_limits['max'];
    }
    else {
      $attributes['max'] = $date_limits['max'];
    }
  }

  if ($has_time && empty($granularity['second'])) {
    $attributes['time']['step'] = 60;
  }

  return $attributes;
}