---
title: "What if a field title ends with a question mark?"
url: "/articles/what-if-a-field-title-ends-with-a-question-mark"
type: article
date: 2006-10-27
updated: 2014-05-15
---

# What if a field title ends with a question mark?

#  What if a field title ends with a question mark? 

 By

 [  Jeff Robbins   ](/about/jeff-robbins) 

 October 27, 2006

  

 Can you tell us a little bit about yourself?: Isn't it kind of annoying that there is a colon right after the question mark?

I know this one has been bothering [Matt](https://www.lullabot.com/about/mattwestgate) for a long time. He's even [submitted a core patch for it](http://drupal.org/node/67211). But nothing has gotten in yet due to translation problems.

However I ran into this problem again while putting together our new [contact form](https://www.lullabot.com/contact_work) (using the amazing [Webform Module](http://drupal.org/project/webform)). I decided to solve it in our theme and thought others might want to use this trick.

By copying the *theme\_form\_element()* function from the *theme.inc* and pasting it into our *template.php* file, we can do a little checking to see if the form element title ends with a punctuation character. And if so, suppress the trailing colon.

Here's what it looks like for Drupal 4.7. I'm guessing it'll be pretty similar, if not completely the same for Drupal 5:

  ```php

/**
 * Rewrite of theme_form_element() to suppress ":" if the title ends with a punctuation mark.
 */
function phptemplate_form_element($title, $value, $description = NULL, $id = NULL, $required = FALSE, $error = FALSE) { 

  $output  = '<div>'."\n"; 
  $required = $required ? '<span>*</span>' : ''; 

  if ($title) { 
    // I've added the next two lines
    $punctuation = array(',', '.', '?', '!', ':');
    $colon = in_array($title[strlen($title)-1], $punctuation) ? '' : ':';
    if ($id) {
      // I've modified this next bit
      $output .= ' '
        . t('%title%colon %required', array('%title' => $title, '%required' => $required, '%colon' => $colon))
        . "\n";
    } 
    else { 
      // and this one too
      $output .= ' '
        . t('%title%colon %required', array('%title' => $title, '%required' => $required, '%colon' => $colon))
        . "\n"; 
    } 
  } 

  $output .= " $value\n"; 

  if ($description) { 
    $output .= ' <div>'. $description ."</div>\n"; 
  } 

  $output .= "</div>\n"; 

  return $output; 
}
  
```

Sorry about the weird output. Some of the lines are a bit long.

 

   You must have JavaScript enabled to use this form.

## Get in touch with us

### Tell us about your project. We'd love to hear from you!

 First Name  

 Last Name  

 Your email address  

 Your organization  

 How you heard about us  

 Tell us more 

     Leave this field blank