You are here

function filefield_generic_edit_process in FileField 6.2

The 'process' callback for 'filefield_generic_edit' form elements. Called after defining the form and while building it, transforms the barebone element array into an icon and and a text field for editing the file description.

1 string reference to 'filefield_generic_edit_process'
filefield_elements in ./filefield.module
Implementation of hook_elements().

File

./filefield.module, line 778

Code

function filefield_generic_edit_process($element, $edit, &$form_state, $form) {
  $field = $element['#field'];
  $delta = $element['#delta'];
  $file = $element['#file'];
  $url = file_create_url($file->filepath);
  $prefix = isset($element['#prefix']) ? $element['#prefix'] : '';
  $suffix = isset($element['#suffix']) ? $element['#suffix'] : '';
  $element['#prefix'] = $prefix . '<div class="filefield-generic-edit">';
  $element['#suffix'] = '</div>' . $suffix;
  $element['icon'] = array(
    '#type' => 'markup',
    '#value' => theme('filefield_icon', $file),
  );
  $element['description'] = array(
    '#type' => 'textfield',
    '#default_value' => empty($file->description) ? $file->filename : $file->description,
    '#maxlength' => 256,
    '#description' => t('Size: !size. Filename: !link', array(
      '!size' => format_size($file->filesize),
      '!link' => l($file->filename, $url),
    )),
    '#required' => TRUE,
    '#prefix' => '<div class="filefield-generic-edit-description">',
    '#suffix' => '</div>',
  );
  return $element;
}