By mpapet on
Another newbie question on a submit function that doesn't get called from hook_form_alter.
function cg_volunteer_form_alter(&$form, $form_state, $form_id) {
if ($form['#id'] == 'user-profile-form' || $form['#id'] == 'user_profile_form'){
$form['cg_edit_me']['cg_phrase'] = array(
'#type' => 'textfield',
'#title' => t('Enter a happy phrase'),
'#maxlength' => 130,
);
$form['cg_edit_me']['contact_submit'] = array(
'#type' => 'submit',
'#value' => t('Update Phrase'),
'#submit' => array('cg_custom_user_submit'),
'#validate' => array('cg_user_edit_validate'),
}
}
function custom_user_submit($form, &$form_state) {
drupal_set_message($message = 'Contact information has been updated', $type = 'status', $repeat = TRUE);
watchdog('cg_volunteer', 'cg insert might have happened.', array(), WATCHDOG_NOTICE, $link = NULL);
}
The cg_user_edit_validate works great. In theory, I would see "cg insert might have happened" in the Recent Log Messages. In practice, nothing happens. Where am I going wrong?
Comments
function custom_user_submit
function custom_user_submit should be named cg_custom_user_submit based on what you declared above :
Sorry, It doesn't work
It never processes anything in in function cg_custom_user_submit. Nothing.
Maybe I'm complicating matters in an unexpected way? The modified form is the user's 'edit' form. Adding my modifications to the form puts two 'submit' functions on the page. Maybe Drupal can't handle that?