2

How do I change the name of the button in the user_profile_form in Drupal 7? I alter the user profile using hook_form_alter().

function userform_form_alter(&$form, &$form_state, $form_id) { 
  if ($form_id == 'user_profile_form' ) { 
    // I define a submit button like:
    $form['submit'] = array( 
      '#type' => 'submit', 
      '#value' => t('Continue'), 
    );

    //Then I can change it with this code:  
    // Change 'Continue' to 'Sign in'. 
    $form['submit']['#value'] = t('Sign in');
  }
}

It works for all elements (buttons) I define myself, but it doesn't work for the default button in the user profile form.
This the rendered HTML for the "Save" button:

<input id="edit-submit" class="form-submit" type="submit" value="Save" name="op">
1

Try using profile_form_alter

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.