0

I'm theming a comments section on a page in a D7 site. What I want is for the label for the forms items to show as a placeholder attribute rather than above the element.

I've used a hook_form_alter to add the placeholder attributes, e.g.

$form['comment_body']['#attributes']['placeholder'] = t('Add comment here');

…but don't seem to be able to hide the label. In a normal form I can set the label to hidden but there's no option under 'manage display' for the comment form.

Is there something I can do in my hook to do it instead? I know I can hide it with CSS but would like to know The Drupal Way™

| improve this question | | | | |
1

Right, answered my own question with a bit of help from the Form API Docs!! https://api.drupal.org/api/drupal/developer!topics!forms_api_reference.html/7

'#title_display' => 'invisible'

was what I needed!

| improve this answer | | | | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.