Image submit buttons on Drupal 5.10

I follow this useful howto by Tom Constant on how to add image submit buttons on Drupal forms. Since I got a JavaScript error on drupal.js (line 31: button is undefined), I rewrite Tom’s implementation, and now it works fine on Drupal 5.10:

function phptemplate_button($element) {
  // Make sure not to overwrite classes.
  if (isset($element['#attributes']['class'])) {
    $element['#attributes']['class'] = 'form-'. $element['#button_type'] .' '.
  else {
    $element['#attributes']['class'] = 'form-'. $element['#button_type'];

  // here the novelty begins: check if #button_type is normal submit
  // button or image button
  switch($element['#button_type']) {
	case 'image': $button_type = 'image';
	default: $button_type = 'submit';
  return '<input id="'. $element['#id'].'" name="'. $element['#name'] .'"
 type="' . $button_type . '" value="'. check_plain($element['#value']) .'" />

2 responses to “Image submit buttons on Drupal 5.10”

  1. Neanche a me da l’accesso diretto.

    Fai così allora:
    – entri qua
    – clicca su “Spore insider” nella riga in alto
    – clicca su “Prototipi” nella colonna a sinistra
    – hai i link con le simulazioni (ce n’era uno che fino a qualche giorno fa non funzionava, non so se ora l’hanno messo a posto)

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: