Skip to content

Instantly share code, notes, and snippets.

@ianoxley
Created December 6, 2010 13:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ianoxley/730311 to your computer and use it in GitHub Desktop.
Save ianoxley/730311 to your computer and use it in GitHub Desktop.
Removing the * to denote required fields and marking all optional fields as "optional" in Drupal
function formutils_form_alter(&$form, &$form_state, $form_id) {
if (is_array($form['submitted'])) {
foreach ($form['submitted'] as $field) {
if (!$field['#required']) {
$currentTitle = $field['#title'];
$field['#title'] = $currentTitle . ' (optional)';
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment