function file_field_widget_value

7.x file.field.inc file_field_widget_value($element, $input = FALSE, $form_state)

The #value_callback for the file_generic field element.

1 string reference to 'file_field_widget_value'
file_field_widget_form in drupal/modules/file/file.field.inc
Implements hook_field_widget_form().

File

drupal/modules/file/file.field.inc, line 581
Field module functionality for the File module.

Code

function file_field_widget_value($element, $input = FALSE, $form_state) {
  if ($input) {
    // Checkboxes lose their value when empty.
    // If the display field is present make sure its unchecked value is saved.
    $field = field_widget_field($element, $form_state);
    if (empty($input['display'])) {
      $input['display'] = $field['settings']['display_field'] ? 0 : 1;
    }
  }

  // We depend on the managed file element to handle uploads.
  $return = file_managed_file_value($element, $input, $form_state);

  // Ensure that all the required properties are returned even if empty.
  $return += array(
    'fid' => 0,
    'display' => 1,
    'description' => '',
  );

  return $return;
}