You are here

function file_entity_add_upload in File Entity (fieldable files) 7.2

Same name and namespace in other branches
  1. 7.3 file_entity.pages.inc \file_entity_add_upload()

Form callback for adding a file via an upload form.

This is a multi step form which has 1-3 pages:

  • Upload file
  • Choose filetype If there is only one candidate (based on mimetype) we will skip this step.
  • Edit fields Skip this step if there are no fields on this entity type.
1 call to file_entity_add_upload()
file_entity_add_upload_multiple in ./file_entity.pages.inc
Form for uploading multiple files.
1 string reference to 'file_entity_add_upload'
file_entity_menu in ./file_entity.module
Implements hook_menu().

File

./file_entity.pages.inc, line 90
Supports file operations including View, Edit, and Delete.

Code

function file_entity_add_upload($form, &$form_state, $options = array()) {
  if (!is_array($options)) {
    $options = array(
      $options,
    );
  }
  $step = isset($form_state['step']) && in_array($form_state['step'], array(
    1,
    2,
    3,
    4,
  )) ? $form_state['step'] : 1;
  $form['#step'] = $step;
  $form['#options'] = $options + array(
    'types' => array(),
    'enabledPlugins' => array(),
    'schemes' => array(),
    'max_filesize' => '',
    'uri_scheme' => file_default_scheme(),
    'plugins' => '',
  );
  switch ($step) {
    case 1:
      return file_entity_add_upload_step_upload($form, $form_state, $options);
    case 2:
      return file_entity_add_upload_step_filetype($form, $form_state, $options);
    case 3:
      return file_entity_add_upload_step_scheme($form, $form_state, $options);
    case 4:
      return file_entity_add_upload_step_fields($form, $form_state, $options);
  }
}