$default_display = EntityFormDisplay::load('user.user.default');
$register_display = $default_display->createCopy('register');

The user.user.default form display is created by the "standard' profile, and it also exists in Umami.
Anyone running the minimal profile won't have it, so the second line is not guaranteed to work.

Comments

bojanz created an issue. See original summary.

bojanz’s picture

We'll need some boilerplate cause #2367933: Move entity_get_(form_)display() to the entity display repository was fixed only for Drupal 8.8.x:

    $user_form_display = EntityFormDisplay::load('user.user.default');
    if (!$user_form_display) {
      $user_form_display = EntityFormDisplay::create([
        'targetEntityType' => 'user',
        'bundle' => 'user',
        'mode' => 'default',
        'status' => TRUE,
      ]);
      $user_form_display->save();
    }

  • bojanz committed 0ace08c on 8.x-1.x
    Issue #3071142 by bojanz: ProfileType::postSave() shouldn't assume that...
bojanz’s picture

Status: Active » Fixed

Done.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.