Skip to content

Instantly share code, notes, and snippets.

@mavimo
Created April 13, 2012 13:05
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 mavimo/2376745 to your computer and use it in GitHub Desktop.
Save mavimo/2376745 to your computer and use it in GitHub Desktop.
Set label as placeholder
<?php
hook_form_FORM_ID_alter(&$form, &$form_state, $form_id) {
set_label_as_placeholder($form);
}
function set_label_as_placeholder(&$form) {
foreach (element_children($form) as $name) {
element_children($form[$name]);
if ($form[$name]['#type'] == 'textfield') {
$form[$name]['#attributes']['placeholde'] = $form[$name]['#title'];
$form[$name]['#title'] = '';
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment