function file_field_widget_process_multiple
file_field_widget_process_multiple($element, &$form_state, $form)
An element #process callback for a group of file_generic fields.
Adds the weight field to each row so it can be ordered and adds a new Ajax wrapper around the entire group so it can be replaced all at once.
File
- modules/file/file.field.inc, line 695
- Field module functionality for the File module.
Code
function file_field_widget_process_multiple($element, &$form_state, $form) { $element_children = element_children($element, TRUE); $count = count($element_children); foreach ($element_children as $delta => $key) { if ($key != $element['#file_upload_delta']) { $description = _file_field_get_description_from_element($element[$key]); $element[$key]['_weight'] = array( '#type' => 'weight', '#title' => $description ? t('Weight for @title', array('@title' => $description)) : t('Weight for new file'), '#title_display' => 'invisible', '#delta' => $count, '#default_value' => $delta, ); } else { // The title needs to be assigned to the upload field so that validation // errors include the correct widget label. $element[$key]['#title'] = $element['#title']; $element[$key]['_weight'] = array( '#type' => 'hidden', '#default_value' => $delta, ); } } // Add a new wrapper around all the elements for Ajax replacement. $element['#prefix'] = '<div id="' . $element['#id'] . '-ajax-wrapper">'; $element['#suffix'] = '</div>'; return $element; }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/modules!file!file.field.inc/function/file_field_widget_process_multiple/7.x