I'm trying to compute a user profile field using values submitted in a custom user profile edit form. I know that the callback is firing, but it won't set the new value in the field. I've tried every incantation I could think of to set it (right now I'm just trying to flat out set it, never mind the calculation). To debug it, I've tried putting a print_r statement in the callback for both $form and $form_state, but it doesn't print anything.
What's the right syntax? Or is it a bigger problem because it's the user profile, or because I'm mixing a module and a .tpl, or something entirely different? The other form fields are all being set as expected.
This is Drupal 7, btw.
My code, way simplified:
In template.php:
function my_theme_theme() {
return array(
'user_profile_form' => array(
'arguments' => array('form' => NULL),
'render element' => 'form',
'template' => 'templates/user-profile-edit'
),
);
}
In my_module.module:
function my_module_form_alter(&$form, &$form_state, $form_id) {
if ($form_id == 'user_profile_form') {
$form['#submit'][] = 'my_module_compute_values';
}
}
function my_module_compute_values (&$form, &$form_state) {
$form_state['field_age']=300;
}