Make WordPress Core

Opened 10 years ago

Closed 9 years ago

Last modified 9 years ago

#33918 closed defect (bug) (duplicate)

WordPress media modal window issue with custom fields

Reported by: simonrcodrington's profile simonrcodrington Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Gallery Keywords:
Focuses: Cc:

Description

Hey everyone, I've found a potential bug in the gallery grid media manager.

There are two places where you can edit the info about an 'attachment', either on its single attachment page or dynamically via the attachment modal window (that opens up when you select an item in newer wordpress versions).

I hooked onto the 'attachment_fields_to_edit' and 'attachment_fields_to_save' hooks so I could add new elements and save them (text field, select list etc).

What I found is. If I try and create a multi-value check list (e.g what colours do you like, 'red','green','blue' etc) the modal window for the atttachment won't save their values. As in you will see a list of checkboxes and when you select an option it instantly does its Ajax call to save the value. So you will use the form and select a few options from the checkbox and it all looks good, however when you actually go into the attachment the values are not saved.

Most other examples I've seen where people are adding fields to the media elements include text fields, select items etc. I think the issue could be that it doesn't expect / can't handle elements that are arrays such as 'name="colours[]". when I just have a single item like a text field with 'name="colour"' it works fine.

I've created a small plugin that you can use to replicate the issue:

http://www.filedropper.com/wordpressmediamodalbugplugin

You need to select a media item in the grid mode and it will show you a list of colours. If you select them nothing happens. However if you go into the full page with 'edit more details' it works perfectly.

Simon

Attachments (7)

wordpress_media_modal_bug_plugin.zip (1.5 KB) - added by simonrcodrington 10 years ago.
Contains sample code to illustrate the issue with the attachment fields not saving when using multiple checkboxes
wordpress_media_modal_bug_plugin.2.zip (1.5 KB) - added by simonrcodrington 10 years ago.
Plugin to illustrate my issue with the media edit fields. Multi checkboxes don't update their values
wordpress_media_bug_1.jpg (125.3 KB) - added by simonrcodrington 10 years ago.
Media modal window opened. Currently there are no colours selected
wordpress_media_bug_2.jpg (125.2 KB) - added by simonrcodrington 10 years ago.
Media window opened. Now we have selected two colours to be saved. It all looks good but nothing happens in the back-end
wordpress_media_bug_3.jpg (13.4 KB) - added by simonrcodrington 10 years ago.
Inside the actual media item (in edit mode). The colours have not been changed
wordpress_media_bug_4.jpg (24.3 KB) - added by simonrcodrington 10 years ago.
We manually selected the colours we want now inside the full attachment editor
wordpress_media_bug_5.jpg (125.7 KB) - added by simonrcodrington 10 years ago.
When we save and update the media attachment, when we view the modal window in the gallery grid view again all of the colours are checked.

Download all attachments as: .zip

Change History (9)

@simonrcodrington
10 years ago

Contains sample code to illustrate the issue with the attachment fields not saving when using multiple checkboxes

@simonrcodrington
10 years ago

Plugin to illustrate my issue with the media edit fields. Multi checkboxes don't update their values

@simonrcodrington
10 years ago

Media modal window opened. Currently there are no colours selected

@simonrcodrington
10 years ago

Media window opened. Now we have selected two colours to be saved. It all looks good but nothing happens in the back-end

@simonrcodrington
10 years ago

Inside the actual media item (in edit mode). The colours have not been changed

@simonrcodrington
10 years ago

We manually selected the colours we want now inside the full attachment editor

@simonrcodrington
10 years ago

When we save and update the media attachment, when we view the modal window in the gallery grid view again all of the colours are checked.

#1 @Asgaros
9 years ago

  • Resolution set to duplicate
  • Status changed from new to closed
  • Version 4.3 deleted

Hello simonrcodrington,

I just stumbled into the same problem when using multiple checkboxes with the same name which should be passed as an array. I saw that this issue gets already tracked in this ticket: #28053. So I will mark this ticket as a duplicate. :)

#2 @netweb
9 years ago

  • Milestone Awaiting Review deleted
Note: See TracTickets for help on using tickets.