Is there any way to change Drupal's default HTML tag?
For instance, I want to change:

to

(the HTML above can be seen in log in submission)

Because it conflicts with w3c HTML validation, thus making my site invalid. Thanks. :)

Comments

Deathlock’s picture

Ah, I forgot the code tag.
I mean:
<input type="submit" name="op" id="edit-submit" value="Log in" class="form-submit" />
to
<input type="submit" name="op" value="Log in" class="form-submit" />

Thanks.

hualahyja@drupal.org’s picture

try to use redefining drupal theme functions.

for example there is a theme_button() function, which is producing HTML code for a button.
You can override this function using phptemplate engine by creating template.php file in your theme's folder and simply including
new youthemename_button() function into it.

More information on drupal theme functions you can find at api.drupal.org.
And also the online documentation on phptemplate, of course :)

Deathlock’s picture

Thanks..
I've tried to add the function into phptemplate but it seems won't work.

I'm trying to change:

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

  return '<input type="submit" '. (empty($element['#name']) ? '' : 'name="'. $element['#name'] .'" ') .'id="'. $element['#id'] .'" value="'. check_plain($element['#value']) .'" '. drupal_attributes($element['#attributes']) ." />\n";
}

into

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

  return '<input type="submit" '. (empty($element['#name']) ? '' : 'name="'. $element['#name'] .'" ') .'" value="'. check_plain($element['#value']) .'" '. drupal_attributes($element['#attributes']) ." />\n";
}

(notice that the ID has gone on the 2nd quotation)
But even though I have put away the ID attribute on phptemplate, actually on the site it's just still there. It seems I can't remove the ID.

I'm using Drupal 5 anyway.

dman’s picture

looks like you're doing the right thing.
Perhaps the id was coming from the attributes, although I wouldn't have thought so from looking at the code.
could

unset($attributes['id']);

or something do the trick?

Did you try putting other test output into that function to see that it's really the one being used?

.dan.
How to troubleshoot Drupal | http://www.coders.co.nz/

dvessel’s picture

Or you can just add this.

/**
 * Fixes illegal duplicate html id's "edit-sumit". Remove in 6.
 */
function phptemplate_submit($element) {
  static $dupe_ids = array();
  if (isset($dupe_ids[$element['#id']])) {
    $dupe_ids[$element['#id']]++;
    $element['#id'] = $element['#id'] .'-'. $dupe_ids[$element['#id']];
  }
  else {
    $dupe_ids[$element['#id']] = 0;
  }
  return theme('button', $element); 
}

Increments for every duplicate it finds.

joon park
www.dvessel.com

Deathlock’s picture

Thanks!
Guess that works. :D

subir_ghosh’s picture

can't make this fix work in Drupal 5. nothing changes. :(

-----------------------------
Subir Ghosh
www.subirghosh.in