You are here

function _commerce_file_limit_element_get_defaults in Commerce File 7

Returns an array of defaults for the given element

2 calls to _commerce_file_limit_element_get_defaults()
commerce_file_limit_duration_element_process in includes/commerce_file.elements.inc
FAPI process callback for limit textfield element type.
commerce_file_limit_integer_element_process in includes/commerce_file.elements.inc
FAPI process callback for limit textfield element type.

File

includes/commerce_file.elements.inc, line 382
Commerce File form elements

Code

function _commerce_file_limit_element_get_defaults($element) {
  $defaults = array(
    'mode' => COMMERCE_FILE_LIMIT_UNLIMITED,
    'value' => NULL,
  );
  if (isset($element['#default_value'])) {
    if (is_array($element['#default_value'])) {
      $defaults = $element['#default_value'] + $defaults;
    }
    elseif (isset($element['#mode_options'][$element['#default_value']])) {
      $defaults['mode'] = $element['#default_value'];
    }
    else {
      $defaults['mode'] = 'value';
      $defaults['value'] = $element['#default_value'];
    }
  }
  return $defaults;
}