We have two cancel buttons on the file edit page. See the attaches screenshot. The Cancel button is added by media browser plus module and the Cancel link is added by the media module. We have to remove one of them.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

boychev’s picture

Status: Active » Needs review
FileSize
526 bytes

I've made a patch for this issue which checks if there is two cancel buttons and if yes - removes one of them. In my case it is better to remove the cancel link, provided by the media module because it does not work properly anyway.

das-peter’s picture

Status: Needs review » Needs work

Are you sure the patch works?
I'm asking because:

  1. I can't find a cancel link / button with an uppercase C (Cancel) as array key, whether in MBP nor Media (version from 09.02.2013)
  2. MBP defines $form['actions']['cancel'] -> "actions", the condition in the patch compares only "buttons".
    So none of the buttons seems to come from MBP -> not an MBP bug?

Btw. the patch contains trailing slashes. I recommend to configure (checkout http://drupal.org/node/147789) your IDE to automatically remove trailing slashes to meet the Drupal Coding Standards. A great help is the Code Sniffer in the Coder Module (7.x-2.x branch).

boychev’s picture

Thanks for recommendations. I attached a screenshot with the all buttons that media_file_page_edit_multiple() function returns in the form. ...['Cancel'] button is the submit button, ...['cancel'] button is the link. I also think this is not a MBP plus bug. Here is the declaration of the cancel button in MBP:

$form['actions']['cancel'] = array(
    '#type' => 'submit',
    '#value' => t('Cancel'),
    '#weight' => 20,
    '#submit' => array('media_browser_plus_edit_cancel'),
  ); 

I'm wondering from where the ['Cancel'] item comes.

das-peter’s picture

A wild guess: "Crop" is written with an uppercase "C" - which module adds this button? Does it add other buttons too? E.g. Save, Delete ...

boychev’s picture

Disabling the module that provides crop functionality does not resolve our problem. I'll make a detailed research from where this should come. Thanks for the effort.

boychev’s picture

I think it will be great to have drupal_alter() function here if we want to make some modifications to the edit multiple form.

das-peter’s picture

Well, basically media_browser_plus_edit_multiple_form is already an alteration of media_file_page_edit_multiple.
Overwrite the menu item with hook_menu_alter(&$items), register your own page callback and there you go - make what ever you'd like in the wrapper function.
But I'm not sure we should encourage developers to mess up this stuff even more by providing an easier way to do so :P
Further, this function was removed in the MBP 3.x branch - so it won't be a long-term solution either.

boychev’s picture

hook_menu_alter also can do the work, but in this case we should rewrite the existing code and there will be duplicated code. In my opinion it is always good to add alter hooks when you build a form.

das-peter’s picture

Actually I want to get rid of MBP 2.x as soon as possible. The whole branch was a pile of code duplication and I stuck with it just because I hadn't time to rewrite it.
Now as I invested quite some time into the 3.x branch I'll prefer to focus on that and not on cleaning up the fubar 2.x version.
I've you really want to stay with the 2.x branch I would happily add you as maintainer - but unfortunately I don't have the permissions to administer maintainers for this project.

salvis’s picture

Issue summary: View changes
Status: Needs work » Closed (outdated)