How can I remove the : from appearing after every label in forms made with the Drupal Form API?

| improve this question | | | | |

Create your own implementation of theme_form_element(). The offending semicolon is in $t('!title: !required', ...), and would need to be removed in both locations.

Not the easiest thing to change, but at least it's possible without hacking core!

| improve this answer | | | | |

The way I've just done it is to add a <span class="colon"><span> around the colon in field.tpl.php. Then I can hide it with display:none; if I don't want it.

It avoids putting a lot of logic into a tpl.php if you have multiple fields which either need or don't need colons.

It also allows you to change fields colon requirements on different pages. For example I often don't want them on displaying a node but would like them in editing.

| improve this answer | | | | |

copy the field.tpl.php to your current theme folder and remove colon. Clear cache and check. I think It will solve the problem.

| improve this answer | | | | |

You can try this also, works for me in drupal 7.

Drop this in the body of your version of 'page.tpl.php' in your template folder.

      'jQuery(document).ready(function () {
        var labels = jQuery(".field-label");
        jQuery.each(labels, function() {
          this.innerHTML = this.innerHTML.replace(":", "");
| improve this answer | | | | |
  • Why was this voted down? Is it a valid way to remove the colons or not? – blue928 May 31 '12 at 6:27
  • 1
    It was probably voted down because it's a client-side only solution. It would be far preferable to do this on the server side, as in Tim's answer – Clive May 31 '12 at 11:28
  • Note that this removes that character everywhere, and not only after the label – Pere Jun 23 '14 at 20:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.