Question

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

Was it helpful?

Solution

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!

OTHER TIPS

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.

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

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.

<?php
    drupal_add_js(
      'jQuery(document).ready(function () {
        var labels = jQuery(".field-label");
        jQuery.each(labels, function() {
          this.innerHTML = this.innerHTML.replace(":", "");
        });
      });',
      'inline');
  ?>
Licensed under: CC-BY-SA with attribution
Not affiliated with drupal.stackexchange
scroll top