#33918 closed defect (bug) (duplicate)
WordPress media modal window issue with custom fields
Reported by: |
|
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)
Change History (9)
@
10 years ago
Plugin to illustrate my issue with the media edit fields. Multi checkboxes don't update their values
@
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
@
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
@
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. :)
Contains sample code to illustrate the issue with the attachment fields not saving when using multiple checkboxes