[wp-trac] [WordPress Trac] #33918: WordPress media modal window issue with custom fields

WordPress Trac noreply at wordpress.org
Fri Sep 18 01:28:47 UTC 2015


#33918: WordPress media modal window issue with custom fields
------------------------------+-----------------------------
 Reporter:  simonrcodrington  |      Owner:
     Type:  defect (bug)      |     Status:  new
 Priority:  normal            |  Milestone:  Awaiting Review
Component:  Gallery           |    Version:  4.3
 Severity:  normal            |   Keywords:
  Focuses:                    |
------------------------------+-----------------------------
 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

--
Ticket URL: <https://core.trac.wordpress.org/ticket/33918>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list