In D7, customer wants to add a button to the user_profile_form. So in my custom module, I create the button and its companion callback. But while the button appears on the form, I see no evidence the callback is being fired.
function member_form_alter(&$form, &$form_state, $form_id) { if ($form_id == "user_profile_form"){ }$form['send_reset'] = array( '#type' => 'button', '#prefix' => "<div id='reset-div'>", '#suffix' => "</div>", '#value' => "Reset member", '#ajax' => [ 'callback' => 'member_reset_user', 'wrapper' => 'reset-div' ], '#weight' => -150, '#attributes' => array( 'id' => array('reset-cancel') ), ); } function member_reset_user($form, &$form_state) { try { my_user_function(): watchdog('member', 'user reset', WATCHDOG_NOTICE); } catch (Exception $e) { watchdog('member', 'reset failed', WATCHDOG_ERROR); } return $form; }
Since I’m not creating new form elements in my callback, just issuing a custom function, I cannot see what I’m doing wrong. I’ve been looking at this too long.