I'm trying to add a new fields with hook_form_alter on user_profile_form. From the core module right now there are:
Password confirm
Pass and re-enter pass
This is the part of my code:
/*
* Implements hook_form_alter().
*/
function mymodule_form_alter (&$form, &$form_state, $form_id) {
switch ($form_id) {
case 'user_profile_form':
$form['account']['telephone'] = array(
'#type' => 'textfield',
'#title' => t('New mobile'),
);
$form['account']['pass_title'] = array(
'#type' => 'markup',
'#markup' => '<div class="profile-pass-title">Password change</div>',
'#weight' => -6,
);
//krumo($form);
break;
}
}
As you can see I've added the telephone field into the form, but when I add text into that text field it doesn't save. The url is user/%/edit. I'm missing something.
The core fields password and email are properly saving.
The next thing is to do is when I add a new field on user_profile_form to be displayed into user/%.
Previously I've mention admin/config/people/accounts/fields, when I add a field from there let's say "telephone" it's working great. On user/%/edit is appearing as a form field and on user/% the result is rendering well. But my idea is: when I've added this field I want to have a title over the "telephone" field result. The title will be "Changing telephone" and bellow will be displayed the "telephone" field result (the result is what the user filled in the textfield on user/%/edit).
@Alfred Armstrong post helped a lot.
With The Field group module this is possible to achieve. It's amazing that on user_profile_form I can use fieldset and wrap the field into, it displays into user/%/edit and on display field that render the results on user/% I can use different fieldset and with little CSS I can do exactly what I want. Many thanks to Alfred Amstrong for showing me this module and thank you all who helped me to find an aswer for this task. I wish I could add +1 to you all :)