You are here

function file_entity_edit in File Entity (fieldable files) 7

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

Form builder: Builds the edit file form.

1 string reference to 'file_entity_edit'
file_entity_page_edit in ./file_entity.pages.inc
Menu callback; presents the Media editing form.

File

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

Code

function file_entity_edit($form, $form_state, $file) {
  $form_state['file'] = $file;
  field_attach_form('file', $file, $form, $form_state);
  $form['preview'] = array(
    '#theme' => 'file_link',
    '#file' => $file,
  );

  // Add the buttons.
  $form['actions'] = array(
    '#type' => 'actions',
  );
  $form['actions']['delete'] = array(
    '#type' => 'submit',
    '#value' => t('Delete'),
    '#weight' => 15,
    '#submit' => array(
      'file_entity_delete_submit',
    ),
  );
  $form['actions']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save'),
    '#weight' => 5,
    '#submit' => array(
      'file_entity_edit_submit',
    ),
  );

  // Add internal file properties needed by media_edit_validate().
  foreach (array(
    'fid',
    'type',
  ) as $key) {
    $form[$key] = array(
      '#type' => 'value',
      '#value' => $file->{$key},
    );
  }
  return $form;
}