Override Drupal’s form “required” asterisk to an arbitrary string

Great tip on overriding Drupal’s required string using form api. Just put into your theme’s template.php:

function THEME_form_required_marker($variables) {
  // This is also used in the installer, pre-database setup.
  $t = get_t();
  $attributes = array(
    'class' => 'form-required',
    'title' => $t('This field is required.'),
  return '<span' . drupal_attributes($attributes) . '>(required)</span>';

Source and further reading: http://knackforge.com/blog/selvam/drupal-form-api-overriding-required-field-asterisk

Leave a Reply