Problem/Motivation

In #3034242: Hide "Save and insert" and "Additional selected media" from users by default this was added/changed

+++ b/core/modules/media_library/src/Form/AddFormBase.php
@@ -461,26 +461,32 @@ protected function buildSelectedItemElement(MediaInterface $media, array $form,
-      'save_insert' => [
-        '#type' => 'submit',
-        '#value' => $this->t('Save and insert'),
-        '#ajax' => [
-          'callback' => '::updateWidget',
-          'wrapper' => 'media-library-add-form-wrapper',
-        ],
-      ],
     ];
+    if ($this->isAdvancedUi()) {
+      $actions['save_select']['#value'] = $this->t('Save and select');
+      $actions['save_insert'] = [
+        'save_insert' => [
+          '#type' => 'submit',
+          '#value' => $this->t('Save and insert'),
+          '#ajax' => [
+            'callback' => '::updateWidget',
+            'wrapper' => 'media-library-add-form-wrapper',
+          ],
+        ],
+      ];

As you can see, 'save_insert' is nested in another 'save_insert' wrapper, this seems excessive and makes it weird DX when altering this form.

Proposed resolution

Not sure if we can still remove this, since it would break BC, and no idea how we would deprecate this.

Remaining tasks

Determine if we can/want to fix this

User interface changes

none

API changes

none

Data model changes

the form will have a different structure, which might break code trying to alter this form.

Release notes snippet

CommentFileSizeAuthor
#2 3127838-2.patch1000 bytesLendude
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Lendude created an issue. See original summary.

Lendude’s picture

Lets take it out and see if this breaks anything....

Lendude’s picture

Status: Active » Needs review
msuthars’s picture

Assigned: Unassigned » msuthars
msuthars’s picture

Status: Needs review » Reviewed & tested by the community

@Lendude Thanks for the patch. I tested it and it working as expected.

msuthars’s picture

Assigned: msuthars » Unassigned
phenaproxima’s picture

+1; this looks like it was an error to begin with. Thanks for noticing this!

  • catch committed f89fcba on 9.1.x
    Issue #3127838 by Lendude: In MediaLibrary the 'save and insert' is...

  • catch committed 0d20805 on 9.0.x
    Issue #3127838 by Lendude: In MediaLibrary the 'save and insert' is...

  • catch committed e4a020b on 8.9.x
    Issue #3127838 by Lendude: In MediaLibrary the 'save and insert' is...
catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 9.1.x/9.0.x/8.9.x, thanks!

Status: Fixed » Closed (fixed)

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