I'd like to bring a lightbox.js UI element into the Audio module so that when you submit a song, the long lonely wait for an upload is improved with a fade-out and a simple update bar. The lightbox.js page (http://www.creativeruin.com/index.cfm/article/32944) has everything I need, but I can't make heads or tails out of the hook-laden form in audio.module. In a simple form, it's called as easily as:
<input type="submit" name="submit" value="Submit" rel="lightboxform" />
Where would I make the call with audio.module?

Comments

sinker’s picture

Title: want to bring lightbox into upload » want to add #suffix to FINAL submit button

I've re-titled this support entry, and can now clarify after some more research:

I want the last submit button on the audio upload page to have this simple text added as a suffix:

rel="lightboxform"

Now, I've added this to the PHP:

  $form['audio_submit'] = array(
    '#suffix' => 'rel="lightboxform"',
  );

where it seems all the other arrays are being defined, but (1) I'm not sure I'm even defining the right submit function, as there are so many and (2) I'm not seeing it in the source code of the rendered page, so clearly I'm doing something wrong.

For the life of me, I don't know what. Thanks in advance for any and all help!

sinker’s picture

any help?

drewish’s picture

you'd need to do that through a hook_form_alter() since the node.module is what puts the submit button onto the form.

sinker’s picture

Can you walk me through this a little bit more completely? I'm new to these types of modifications.

zirafa’s picture

Status: Active » Closed (won't fix)

Unfortunately this is more of a general drupal coding question, so marking as won't fix.

But I believe what you want to do is actually add rel="lightboxform" inside the input.submit element, not after. #suffix and #prefix specify HTML that comes before and after that actual form element.

What I'm guessing you want is:

  $form['audio_submit'] = array(
    '#attributes' => array('rel' => 'lightboxform'),
  );

Go to: http://api.drupal.org/

and scroll down to Form API Quickstart and Form API Reference. Those should help with understanding the Form API system in Drupal.

About Form API #attributes:
http://api.drupal.org/api/file/developer/topics/forms_api_reference.html...

About hook_form_alter
http://api.drupal.org/api/function/hook_form_alter/5

Basically, you want to create a new module, with your own hook_form_alter, and modify audio_node_form to add the #attributes that you want.

Additionally, you can go to #drupal-support in IRC to get real time help.

zirafa’s picture

Also note that you can add this using jQuery, something akin to

$(document).ready(function() {
  $("input").attr("rel","lightboxform");
});