You are here

function s3fs_cors_field_widget_value in S3 File System CORS Upload 7

The #value_callback for the s3fs_cors field element.

This is pretty much a copy of file_field_widget_value(), but modified to use the s3fs_cors_upload_value() function instead of the file.module one.

1 string reference to 's3fs_cors_field_widget_value'
s3fs_cors_field_widget_form in ./s3fs_cors.module
Implements hook_field_widget_form().

File

./s3fs_cors.module, line 427
Allow uploading of files directly to AmazonS3 via the browser using CORS.

Code

function s3fs_cors_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;
    }
  }

  // Handle uploads and the like.
  $return = s3fs_cors_upload_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;
}