You are here

function filefield_widget in FileField 6.2

Same name and namespace in other branches
  1. 5.2 filefield.module \filefield_widget()
  2. 5 filefield.module \filefield_widget()
  3. 6.3 filefield.module \filefield_widget()

Implementation of hook_widget() - the one in filefield.module is just there to include this one on demand.

File

./filefield.widget.inc, line 16
FileField: Defines a CCK file field type.

Code

function filefield_widget(&$form, &$form_state, $field, $items, $delta = 0) {

  // JavaScript might reload the form element but not the CSS that has been
  // defined inside the process hook of mimetype specific widgets. As we don't
  // know which widget will show up, just include all of their CSS files.
  $file_widget_info = _filefield_file_widget_info($field['widget']);
  _filefield_add_css($file_widget_info);
  drupal_add_css(drupal_get_path('module', 'filefield') . '/filefield.css');
  if (!empty($items[$delta]) && ($file = field_file_load($items[$delta]['fid']))) {
    $file = array_merge($items[$delta], $file);
    return filefield_file_edit_form($form, $form_state, $field, $delta, $file);
  }
  return filefield_file_upload_form($form, $form_state, $field, $delta, $items);
}