Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment | File | Size | Author |
---|---|---|---|
#2 | 3127838-2.patch | 1000 bytes | Lendude |
Comments
Comment #2
LendudeLets take it out and see if this breaks anything....
Comment #3
LendudeComment #4
msutharsComment #5
msuthars@Lendude Thanks for the patch. I tested it and it working as expected.
Comment #6
msutharsComment #7
phenaproxima+1; this looks like it was an error to begin with. Thanks for noticing this!
Comment #11
catchCommitted/pushed to 9.1.x/9.0.x/8.9.x, thanks!