Switching the order of buttons: add new <--> add existing

Created on 7 August 2015, almost 9 years ago
Updated 8 January 2024, 6 months ago

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] ?

✨ Feature request
Status

Closed: duplicate

Version

1.6

Component

Code

Created by

πŸ‡¨πŸ‡¦Canada bisonbleu

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024