Closed (fixed)
Project:
Drupal core
Version:
4.7.6
Component:
profile.module
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
10 Aug 2007 at 09:21 UTC
Updated:
19 Feb 2008 at 14:10 UTC
I've been trying for two days to alter the form on one of the user profile edit tabs, but to no avail. It just seems to ignore my hook_form_alter function all together. Here is the simple test that I have been trying (if I could get the thing to listen to me I would add more), which I have added to my template.php file:
function user_edit_form_alter($form_id, &$form) {
if ($form_id == 'user_edit') {
if (isset($form['Personal'])) {
$form['Resume']['test'] = array('#type' => 'checkbox',
'#title' => check_plain('Test'),
'#default_value' => "",
'#description' => 'Tick me',
'#required' => '',
);
}
}
}
I've also placed the function in other locations, such as directly before and after the function profile_user_profile(), but that had no effect. I've also tried renaming the function, things like my_form_alter(), profile_user_profile_form_alter(), and other variations, but that seems to have no effect either.
Does anyone have any experience with doing this?
Thanks,
Chris
Comments
Comment #1
maartenvg commentedSomeone else was having the same problem. Here, http://drupal.org/node/151931#comment-242663, you find some pointers to a solution.
You're supposed to create new tiny module, make a proper hook_alter_form() to add your checkbox and add a submit callback for it.
Another (and easier) way would be to use hook_user in a tiny module with the 'form' operator. That way the value of the checkbox will end up in the $user object, which you then can use elsewhere. (see http://api.drupal.org/api/function/hook_user/4.7)
For example something like this:
Comment #2
ricabrantes commentedissue resolved, Closed..