You are here

function media_gallery_form_media_edit_alter in Media Gallery 7

Implements hook_form_FORM_ID_alter().

File

./media_gallery.module, line 1032

Code

function media_gallery_form_media_edit_alter(&$form, &$form_state) {

  // Adjust the media edit form when it is shown within a gallery context.
  if (isset($form_state['media_gallery']['gallery'])) {

    // Remove the Delete button, since media entities can't be deleted when they
    // are in use.
    $form['actions']['delete']['#access'] = FALSE;

    // Instead, provide a "Remove" checkbox to let users remove the item from
    // the gallery.
    _media_gallery_add_remove_checkbox($form, $form_state, $form_state['media_gallery']['gallery']);

    // Add a submit handler to alter $form_state['redirect'] to the
    // in-gallery-context View page. It's annoying to have to add a submit
    // handler for this, but see http://drupal.org/node/579366#comment-2099836.
    // Make sure to add this for the form-level submit handlers and also for the
    // button-level submit handlers of the "Save" button, in case those are
    // being used.
    $form['#submit'][] = 'media_gallery_media_edit_submit';
    if (isset($form['actions']['submit']['#submit'])) {
      $form['actions']['submit']['#submit'][] = 'media_gallery_media_edit_submit';
    }
  }
  elseif (($node = menu_get_object()) && arg(2) === 'multiedit' && $node->type === 'media_gallery') {
    _media_gallery_add_remove_checkbox($form, $form_state, $node);
  }
}