title: WordPress Attachment Taxonomy Checkbox Group Not Saving In Grid View
body: <p>I created a taxonomy and attached it to the attachments or Media. </p>
  
  <p>I am using Advanced Custom Fields to add a taxonomy field which is displayed as checkbox group.  It adds the fields correctly to the attachments pages in both grid and list views. </p>
  
  <p>In list view, the fields update properly but in the grid view, it only saves the last checkbox clicked.  This is caused by some sort of onclick function which fires admin-ajax when each checkbox is clicked.  Due to this it only sends the value of the box is clicked.  I am trying to find a way to alter the js functions to add in checkbox groups and multi-select.</p>
  
  <p>Update: I have tracked the function down to an onchange.</p>
  
  <p>function: save </p>
  
  <p>file: media-views.min.js</p>
  
  <p>Code to replicate the issue:</p>
  
  <p>Taxonomy:</p>
  
  <pre><code>function cptui_register_my_taxes() {
      $labels = array(
          "name" =&gt; __( "Image Tags", "" ),
          "singular_name" =&gt; __( "Image Tag", "" ),
      );
      $args = array(
          "label" =&gt; __( "Image Tags", "" ),
          "labels" =&gt; $labels,
          "public" =&gt; true,
          "hierarchical" =&gt; false,
          "label" =&gt; "Image Tags",
          "show_ui" =&gt; true,
          "show_in_menu" =&gt; true,
          "show_in_nav_menus" =&gt; false,
          "query_var" =&gt; true,
          "rewrite" =&gt; false,
          "show_admin_column" =&gt; false,
          "show_in_rest" =&gt; false,
          "rest_base" =&gt; "imagetags",
          "show_in_quick_edit" =&gt; false,
      );
      register_taxonomy( "imagetags", array( "attachment" ), $args );
  }
  add_action( 'init', 'cptui_register_my_taxes' );
  </code></pre>
  
  <p>Custom Fields:</p>
  
  <pre><code>if( function_exists('acf_add_local_field_group') ):
      acf_add_local_field_group(array(
          'key' =&gt; 'group_5bc3f242c39e3',
          'title' =&gt; 'Gallery - Image Tags',
          'fields' =&gt; array(
              array(
                  'key' =&gt; 'field_5bc3f249f009c',
                  'label' =&gt; 'Image Tags',
                  'name' =&gt; 'new_image_tags',
                  'type' =&gt; 'taxonomy',
                  'instructions' =&gt; '',
                  'required' =&gt; 0,
                  'conditional_logic' =&gt; 0,
                  'wrapper' =&gt; array(
                      'width' =&gt; '',
                      'class' =&gt; '',
                      'id' =&gt; '',
                  ),
                  'taxonomy' =&gt; 'imagetags',
                  'field_type' =&gt; 'checkbox',
                  'add_term' =&gt; 1,
                  'save_terms' =&gt; 1,
                  'load_terms' =&gt; 1,
                  'return_format' =&gt; 'id',
                  'multiple' =&gt; 0,
                  'allow_null' =&gt; 0,
              ),
          ),
          'location' =&gt; array(
              array(
                  array(
                      'param' =&gt; 'attachment',
                      'operator' =&gt; '==',
                      'value' =&gt; 'all',
                  ),
              ),
          ),
          'menu_order' =&gt; 0,
          'position' =&gt; 'normal',
          'style' =&gt; 'default',
          'label_placement' =&gt; 'top',
          'instruction_placement' =&gt; 'label',
          'hide_on_screen' =&gt; '',
          'active' =&gt; 1,
          'description' =&gt; '',
      ));
  
  endif;
  </code></pre>
  
  <p>You can also remove the default taxonomy field if you want with the following code.  It does not effect the code but removes the text field:</p>
  
  <pre><code>// Remove taxonomy from the attachment pages so the acf taxonomy can work
  add_action( 'admin_menu', function (){ remove_meta_box('imagetagsdiv', 'attachment', 'side' ); } );
  
  // Add this in to remove it from the popup editor
  add_filter( 'attachment_fields_to_edit', function( $fields ){
      unset($fields['imagetags']); 
      return $fields;
  } );
  </code></pre>
  
  <p><strong>Problem Found</strong> Now to find a solution</p>
  
  <p>Open wp-includes/js/media-views.js  - Line: 8353</p>
  
  <pre><code>_.each( this.$el.serializeArray(), function( pair ) {
      data[ pair.name ] = pair.value;
  });
  </code></pre>
  
  <p>It appears they used this code to prevent duplicates but in effect it is deleting everything that can be submitted as an array.  </p>
  
  <p>Note: This is the full file WP loads the .min version by default</p>