Image as form submit I am building a custom form inside a block that has a clickable image as submit.

Here the screenshot of the outcome:



Here is the form code:

function my_form($form, &amp;$form_state) {
  $image = '#';

  if (module_exists('my_base') &amp;&amp; function_exists('my_base_get_form_settings')){
    $image = my_base_get_form_settings('IMAGE');
    $form['my_text'] = array(
      '#markup' =&gt; '&lt;p&gt;'.my_base_get_form_settings('BODY').'&lt;/p&gt;'
    );
  }
  $form['submit'] = array(
    '#type' =&gt; 'image_button',
    '#src' =&gt; $image,
    '#attributes' =&gt; array(
                      'style' =&gt; 'width:80%',
                      'OnSubmit' =&gt; 'my_function();return false;'),
  );
  return $form;
}


I want the image to be clickable and to run the javascript, but without the ugly style of the default button. I didn't find any example that matched my needs.

How to I properly build an image submit in drupal 7? This is obviusly not the right way.
You could try a modification of this: found it here.

&lt;?php
function theme_form_comment_form_alter(&amp;$form, &amp;$form_state, &amp;$form_id) {

  $form['actions']['submit']['#type'] = 'image_button';
  $form['actions']['submit']['#src'] = base_path() . path_to_theme() . '/img/button-off.gif';
  $form['actions']['submit']['#attributes']['title'] = t('Create Comment');
  $form['actions']['submit']['#attributes']['onmouseover'] = "this.src='" . base_path() . path_to_theme() . "/img/button-on.gif'";
  $form['actions']['submit']['#attributes']['onmouseout'] = "this.src='" . base_path() . path_to_theme() . "/img/button-off.gif'";

}
?&gt;