Make WordPress Core

Ticket #33331: b5f7e356884b2cffdd859c11499225d0bd4a821b.diff

File b5f7e356884b2cffdd859c11499225d0bd4a821b.diff, 2.2 KB (added by LindsayBSC, 10 years ago)

media-views.js file patch

  • wp-includes/js/media-views.js

    diff --git a/wp-includes/js/media-views.js b/wp-includes/js/media-views.js
    index 0f53b0a..e6709d1 100644
    a b AttachmentCompat = View.extend({ 
    23512351                }
    23522352
    23532353                _.each( this.$el.serializeArray(), function( pair ) {
    2354                         data[ pair.name ] = pair.value;
    2355                 });
    2356 
    2357                 this.controller.trigger( 'attachment:compat:waiting', ['waiting'] );
    2358                 this.model.saveCompat( data ).always( _.bind( this.postSave, this ) );
    2359         },
    2360 
    2361         postSave: function() {
    2362                 this.controller.trigger( 'attachment:compat:ready', ['ready'] );
    2363         }
    2364 });
     2354               
     2355                /*
     2356                 * Start of patch to fix multiple value input fields
     2357                 *
     2358                 */
     2359                       
     2360                            // if the pair.name is greater than 2 chars and [] is the last two chars
     2361                                if ( pair.name.length > 2 && '[]' == pair.name.substr( pair.name.length - 2 ) ) {
     2362                               
     2363                                                                                // defined item as the name minus the []
     2364                                                            var item = pair.name.substr( 0, pair.name.length - 2 );
     2365                                                                //if item wasn't passed previously in data
     2366                                                             if ( item in data ) {
     2367                                                                          // combine all of the pair.value together to one data[item] comma separated
     2368                                                                      var list =  data[ item ] += ',' + pair.value;
     2369                                                                     
     2370                                                                      // split the list into a javascript object
     2371                                                                      data[ item ] = list.split(',');
     2372                                                                     
     2373                                                             /*   
     2374                                                              * if it is the first time sending for 'item' just add once   
     2375                                                              * storing even single records as an array only for inputs that have name="somename[]"
     2376                                                              */
     2377                                                                  } else {
     2378                                                                        var list = pair.value;
     2379                                                                        data[ item ] = list.split(',');
     2380                                                                  } // end  if ( item in data )
     2381                                             
     2382                                             //else if name does not end in []                     
     2383                                            } else {
     2384                                                 // send the value only
     2385                                                 data[ pair.name ] = pair.value;
     2386                                           }
     2387                        });
    23652388
    23662389module.exports = AttachmentCompat;
    23672390