In my use case, letting a user build a team of employees, it makes more sense to first have [Add existing content] and then [Add new content].

In other words, the first action I want a user to consider (in a LTR world) is to look for an existing user. If one cannot be found, then the user can create a new one. Logically, this should help reduce duplicates.

I was able to achieve this by simply moving the following block of code (line 726)

      if ($controller->getSetting('allow_existing')) {
        $element['actions']['ief_add_existing'] = array(
          '#type' => 'submit',
          '#value' => t('Add existing @type_singular', array('@type_singular' => $labels['singular'])),
          '#name' => 'ief-' . $ief_id . '-add-existing',
          '#limit_validation_errors' => array(array_merge($parents, array('actions'))),
          '#ajax' => array(
            'callback' => 'inline_entity_form_get_element',
            'wrapper' => $wrapper,
          ),
          '#submit' => array('inline_entity_form_open_form'),
          '#ief_form' => 'ief_add_existing',
        );
      }

above line 688 which starts with

      // The user is allowed to create an entity of at least one bundle.
      if (count($settings['create_bundles'])) {
        // Let the user select the bundle, if multiple are available.
        ...

Are there more use cases where the opposite is true? If not, would it not make sense then to change the button order to [Add existing] [Add new] ?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

bisonbleu created an issue. See original summary.

bisonbleu’s picture

Here's a patch that does this.

dww’s picture

Thanks for the suggestion. This is being fixed at #2673548: Prioritize 'add existing' in nested entity creation UX to prevent duplication.. Although that's a newer issue, it's got much more progress and effort into it. So marking this one as a duplicate. Hopefully a maintainer will credit you over there.

bisonbleu’s picture

Ha ha, 8 years in the coming ;-)
Thanks @dww and cheers!