I want to move the email address fields in the user profile form (user/1/edit) in a custom fieldset. I have this code:
$form['change_mail'] = array(
'#type' => 'fieldset',
'#title' => 'change email address cake',
'#weight' => 6,
'#collapsible' => FALSE,
'#tree' => FALSE,
);
$form['change_mail']['mail'] = $form['account']['mail'];
unset($form['account']['mail']);
$form['change_mail']['confirm_mail'] = $form['account']['confirm_mail'];
unset($form['account']['confirm_mail']);
But I get an error when I try to change my email address: undefined index 'mail' in user_account_form_validate() (line 1232 of /modules/user/user.module).
Apparently, I can't 'unset' the fields. But I don't know how to get rid of them.
$form['change_mail'] = array( ... '#tree' => FALSE,);