Instead of user_register_form (new user creation) and user_profile_form (existing user edit) can't these be called together?, at the very least with a wrapper?

Although two hook_form_FORM_ID_alter s are needed, I don't quite understand why.
The alternative is hook_form_alter() and check the form_id for both.

Maybe I've missed something, but this seems a tad counter to Drupal's typical approach to altering forms.

For instance, I want to add a custom checkbox to the user form (obviously ignoring the Field UI at the moment):

function mymodule_form_alter($form, &$form_state, $form_id) {
  if ($form_id == 'user_register_form' || $form_id == 'user_profile_form') {
    $form['like_donuts'] = array(
      '#title' => t('Tick the box if you like donuts.'),
      '#type' => 'checkbox',
      '#default_value' => !empty($form_state['values']['like_donuts']) ? $form_state['values']['like_donuts'] : '',
    );
  }
}

Comments

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

dpi’s picture

Issue summary: View changes
Status: Active » Closed (won't fix)

They're two forms, so they have two ID's