Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi,
I am trying to use automodal to edit user profile.
I managed to load the user_profile_form form, but whenever I hit the save button, I got the following error:
Notice: Undefined index: user in user_profile_form_submit() (Zeile 307 von /var/www/html/cms/modules/user/user.pages.inc).
I already load user.pages in my modul hook_init:
function ctools_user_edit_init()
{
form_load_include($form_state, 'inc', 'user', 'user.pages');
// module_load_include('inc', 'user', 'user.pages');
global $user;
}
But this even does not help.
My hook_menu is:
function ctools_user_edit_menu() {
$items = array();
$items['edit-social'] = array(
'title' => 'Edit user social links',
'description' => 'Here are some explanations for the user social edit form',
'page callback' => 'drupal_get_form',
'page arguments' => array('ctools_user_edit_contact_us_form'),
'access arguments' => array('access content'),
);
return $items;
}
Comments
Comment #1
vistree CreditAttribution: vistree commentedComment #2
wojtha CreditAttribution: wojtha commented@vistree look at #1450372: How to: How to handle two forms in one modal (unified login page) here is working example for register form and signup form both placed in the single modal. It might help.
Regarding the example you posted it seems that form is submitted to the right handler but the form handler is missing 'user' value in the
$form_state
.Look here: https://github.com/drupal/drupal/blob/7.x/modules/user/user.pages.inc#L307
If you look in the original form, you'll see the following:
Do you have this code inside your
ctools_user_edit_contact_us_form
function?Comment #3
vistree CreditAttribution: vistree commentedHi wojtha,
thank you very much for your feedback. The error has gone. But unfortunately the user edits are not saved.
Comparing the links you sent me, let me ask something: could it be, that I have to use an other page callback?
In the moment, I use 'drupal_get_form'. Is this fine for a user edit form?
Comment #4
wojtha CreditAttribution: wojtha commentedIt can be many things.... maybe missing category (profile is split to several pages which each represent a 'category'), account, or wrong structure of the form data.
Debug
user_profile_form_submit()
with dvm() or dpm() to see what is happening. Or create your own validation and submit handlers (copy the body ofuser_profile_form_validate()
anduser_profile_form_submit()
and tweak them to get 100% control over the form submission.Comment #5
yogeshchaugule8 CreditAttribution: yogeshchaugule8 commentedThis is older thread, but here is how we can get it working.
1. Implement hook_menu_alter and alter profile edit form to be rendered in ctools modal:
2. Implement hook_form_alter and add following code:
3. Implement submit handler.
NOTE: All of above code will go into the custom module.