Support

Account

Home Forums ACF PRO Select2 issue since 5.2.8

Solved

Select2 issue since 5.2.8

  • Hello,

    I recently came across an issue that I can’t seem to find out what is happening.

    I use a multidimensional Select field (opt groups + options) and
    For helping understanding I have posted the field array below (which I amend using the filter acf/load_field/name=xxx):

    Array
    (
        [ID] => 0
        [key] => field_5528355eab6e2
        [label] => Column width(s)
        [name] => column_width
        [prefix] => 
        [type] => select
        [value] => 
        [menu_order] => 1
        [instructions] => 
        [required] => 0
        [id] => 
        [class] => 
        [conditional_logic] => 0
        [parent] => field_5528354bab6e1
        [wrapper] => Array
            (
                [width] => 
                [class] => 
                [id] => 
            )
    
        [_name] => column_width
        [_input] => 
        [_valid] => 1
        [choices] => Array
            (
                [medium] => Array
                    (
                        [medium-12] => 1/1 Medium
                        [medium-6] => 1/2 Medium
                        [medium-4] => 1/3 Medium
                        [medium-3] => 1/4 Medium
                        [medium-2] => 1/6 Medium
                        [medium-1] => 1/12 Medium
                        [medium-5] => 5/12 Medium
                        [medium-7] => 7/12 Medium
                        [medium-8] => 2/3 Medium
                        [medium-9] => 3/4 Medium
                        [medium-10] => 5/6 Medium
                        [medium-11] => 11/12 Medium
                    )
    
                [large] => Array
                    (
                        [large-12] => 1/1 Large
                        [large-6] => 1/2 Large
                        [large-4] => 1/3 Large
                        [large-3] => 1/4 Large
                        [large-2] => 1/6 Large
                        [large-1] => 1/12 Large
                        [large-5] => 5/12 Large
                        [large-7] => 7/12 Large
                        [large-8] => 2/3 Large
                        [large-9] => 3/4 Large
                        [large-10] => 5/6 Large
                        [large-11] => 11/12 Large
                    )
    
                [small] => Array
                    (
                        [small-12] => 1/1 Small
                        [small-6] => 1/2 Small
                        [small-4] => 1/3 Small
                        [small-3] => 1/4 Small
                        [small-2] => 1/6 Small
                        [small-1] => 1/12 Small
                        [small-5] => 5/12 Small
                        [small-7] => 7/12 Small
                        [small-8] => 2/3 Small
                        [small-9] => 3/4 Small
                        [small-10] => 5/6 Small
                        [small-11] => 11/12 Small
                    )
    
            )
    
        [default_value] => Array
            (
            )
    
        [allow_null] => 1
        [multiple] => 1
        [ui] => 1
        [ajax] => 0
        [placeholder] => 
        [disabled] => 0
        [readonly] => 0
    )

    Some facts:
    – See attachment what is happening.
    – This is only happening with Stylised UI enabled (= Select2). When I disable this option the choices show as selected.
    – I figured out that this resolves itself when I downgrade to version 5.2.7. -> it seems to have something to do with ‘Select2’ as there was an update mentioned in the changelog.

    Hopefully you can figure out what’s wrong. I haven’t had the spare time otherwise I would have been happy to supply a fix.

    Thanks!

  • I know that the version of select2 used by ACF was updated and that there are plans to update to the newest version as well at some point. I will flag this for the developer’s attention.

  • Any progress on this? I still cannot update to the latest version without having to manually replace the Select2 with the previous version to get this fixed.

  • This reply has been marked as private.
  • Hi @dennisriddergmail-com

    Thanks for the bug report.

    I’ll be looking into this today. Can you please post the fix here?

    Thanks
    E

  • Hi Elliot,

    Sure, here it is:

    This goes in the acf-input.js, around line 6500 (I have added console logs hence the approx.):

    			// re-order options
    			$.each( selection, function( k, value ){
    				
    				$.each( select2_args.data, function( i, choice ){
    
    					if ( typeof choice.children !== 'undefined' && choice.children.length ) {
    						$.each( choice.children, function( j, choice ) {
    							if ( value == choice.id )
    								initial_selection.push( choice );
    						});
    					}
    					else
    					{
    						if( value == choice.id ) {
    						
    							initial_selection.push( choice );
    
    							
    						}
    					}
    					
    				});
    							
    			});
    

    Thanks so much!

  • This reply has been marked as private.
  • Hi @dennisriddergmail-com

    I’ve just released a new version 5.3.0 to fix this issue. Please update and let me know how you find it

Viewing 9 posts - 1 through 9 (of 9 total)

The topic ‘Select2 issue since 5.2.8’ is closed to new replies.