function amazons3_field_widget_form_alter in AmazonS3 7.2
Implements hook_field_widget_form_alter().
Override file fields to use our destination function to determine the upload location for a file.
File
- ./
amazons3.module, line 381 - Hook implementations for the AmazonS3 module.
Code
function amazons3_field_widget_form_alter(&$element, &$form_state, $context) {
$field = $context['field'];
$instance = $context['instance'];
if (in_array($field['type'], amazons3_file_like_field())) {
if (field_behaviors_widget('multiple values', $instance) == FIELD_BEHAVIOR_DEFAULT) {
$delta = $context['delta'];
$element[$delta]['#upload_location'] = amazons3_field_widget_uri($field, $instance);
}
else {
// In this case this alter hook is only called once for all items in the
// widget.
foreach (element_children($element) as $delta) {
$element[$delta]['#upload_location'] = amazons3_field_widget_uri($field, $instance);
}
}
}
}