I have created a custom taxonomy for my Attachments called Image Tags slug =’imagetags’. I created a field with type taxonomy and turned on save, load and create and displayed as check boxes. Field name=”new_image_tags” The field shows up properly on all systems.
If I click on the image in grid mode I can check as many as I want but it saves only the last checkbox not all of them. If I view it in list mode it saves all the checkboxes properly. I am assuming this is a glitch in ACF javascript that saves these in grid mode.
I’m having this same issue. Good to know you can work around in list view.
I found the issue and now it is about trying to find the solution.
Open wp-includes/js/media-views.js
Line: 8353
_.each( this.$el.serializeArray(), function( pair ) {
data[ pair.name ] = pair.value;
});
This is the js code wordpress is using to collect the form data for submission. It effectively removes the array submitted. I submitted this as a bug on their forums but we will see how they reply.
This code fixes the WordPress save function. I have also submitted this as a bug so hopefully they fix it.
add_action( 'admin_print_footer_scripts', 'mediaArrayFix', 11 );
function mediaArrayFix() {
// Make sure the media-views script has been enqueued.
if(!did_action( 'wp_enqueue_media' ) ){ return; }
?>
<script>
wp.media.view.AttachmentCompat.prototype.save = function( event ) {
var data = {};
if ( event ) { event.preventDefault(); }
_.each( this.$el.serializeArray(), function( pair ) {
if ( /\[\]$/.test( pair.name ) ) {
if ( undefined === data[ pair.name ] ) { data[ pair.name ] = []; }
data[ pair.name ].push( pair.value );
}else{ data[ pair.name ] = pair.value; }
});
this.controller.trigger( 'attachment:compat:waiting', ['waiting'] );
this.model.saveCompat( data ).always( _.bind( this.postSave, this ) );
};
</script>
<?php
}