0

I've tried using 2 different functions, where both successfully sets the value to 'invisible' with a dsm($form) check. However, the label is still being displayed.

function MYMODULE_form_alter(&$form, &$form_state, $form_id) {
  switch ($form_id) {
          case 'user_register_form':
              $form['profile_users']['field_username']['#title_display'] = 'invisible';
              $form['captcha']['#title_display'] = "invisible";
   break;
  }
}

and:

function MYMODULE_form_profile2_edit_PROFILETYPE_form_alter(&$form, &$form_state){

     $form['profile_PROFILETYPE']['field_username']['#title_display'] = 'invisible';

}

I do not encounter this problem for the username, password and email fields.

Edit: I've also tried:

$form['profile_users']['field_username']['und']['#title'] = '';
$form['profile_users']['field_username']['und']['#title_display'] = "invisible";
1
  • Could you ask it in a form of a question, like "how to ... ?"
    – Mołot
    May 8, 2014 at 6:46

1 Answer 1

0

you can use this code instead:

$form['captcha']['#title'] = '';
5
  • This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post.
    – Mołot
    May 8, 2014 at 7:45
  • title says "Hide profile2 and captcha label in registration form" so how come my answer doesn't answer the question? May 8, 2014 at 7:56
  • If you think it is the way, say it. Not ask. It very much looks like a question, not answer.
    – Mołot
    May 8, 2014 at 7:57
  • $form['captcha']['captcha_widgets']['captcha_response']['#title'] = ''; worked! thanks :)
    – ashash
    May 8, 2014 at 11:01
  • I'm still having problems with profile2 though. I managed to locate #title variable the where the label was printed and changed it to '', and it worked by changing the variable but it isn't reflected in the user register form...
    – ashash
    May 8, 2014 at 11:11

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.