1

i'm trying to theming my user register form. i would like to have a custom function for the username part. So, i'm doing

$form['account']['name']['#theme'] = 'my_custom';

i define my hook_theme and just for testing purpouses, this is my custom function

function theme_my_custom( $variables ){
  return 'testing code...'
}

My problem is when i go to user/register, i still can see the label for my username. Only the input is replaced by the code of my function. I would expect replace the element entirely, but this is not happening.

Any clues? Thanks.

2 Answers 2

1

As you can see on the Form API reference page, '#theme' Only affects the input box itself. To remove other things generated by the form API, you'll have to clear the array -

$form['account']['name']['#title'] => '';
$form['account']['name']['#description'] => '';

or just

$form['account']['name'] = array(...);

To reset existing elements.

0

or you may use #after_build property for your form elements.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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