Move the help/description text
Problem: Users often don't read the help text (found between div class="description" tags) for a form field because it is printed below the field, rather than between the label and the field.
Solution:
1. Add the following lines to your template.php
function phptemplate_form_element($title, $value, $description = NULL, $id = NULL, $required = FALSE, $error = FALSE) {
return _phptemplate_callback('form_element', array('value' => $value, 'title' => $title, 'description' => $description,
'id' => $id, 'required' => $required, 'error' => $error));
}2. Create a form_element.tpl.php file something like:
<?
/**
* Return a themed form element.
*
* @param $title the form element's title
* @param $value the form element's data
* @param $description the form element's description or explanation
* @param $id the form element's ID used by the <label> tag
* @param $required a boolean to indicate whether this is a required field or not
* @param $error a string with an error message filed against this form element
*
* @return a string representing the form element
*/
?>
<div class="form-item">
<?php
$required = $required ? '<span class="form-required" title="'. t('This field is required.') .'">*</span>' : '';
if ($title) {
if ($id) {
print ' <label for="'. form_clean_id($id) .'">'. t('%title: %required', array('%title' => $title, '%required' =>
$required)) . "</label>\n";
} else {
print ' <label>'. t('%title: %required', array('%title' => $title, '%required' => $required)) . "</label>\n";
}
}
if ($description) {
print ' <div class="description"> '. $description ."</div>\n";
}
print " $value\n";
?>
</div>
how to move the help/description text in Drupal 5.x
I'm working to upgrade this theming override for 5.x. Has anyone done this already?
For 5.x use theme_form_select
There was a small change on http://api.drupal.org/api/function/theme_form_element/5 function in 5.x see http://drupal.org/node/64292#form_element
What I'll do would be simply override theme_form_element and place the description part before the label.