Support

Account

Home Forums Backend Issues (wp-admin) Select field content dependending from previous field Reply To: Select field content dependending from previous field

  • And again, I solved it on my own ^^.
    I ended up with simple input fields.

    If anyone is interested in it, here is my admin.js code and a screencast gif:

    (function($){
        'use strict';
        acf.add_action('append', function( $el ){
            var layout = $el.attr('data-layout');
            if( layout === null || typeof layout === 'undefined') return;
            if( layout && layout.indexOf('_product') === -1 ) return;
    
            var $productAttributes = acf.get_field('', jQuery('.values [data-name="product_attributes"]'));
            var attributes = $productAttributes.find('textarea').val();
    
            $.each( attributes.split(/\n/),  function ( i, attr ) {
                $el.find('a[data-event="add-row"]').last().trigger('click');
                var name_input = $el.find('tr.acf-row:not(.acf-clone) [data-name="attribute_name"] input');
                name_input.last().val(attr);
                //name_input.prop('disabled', true); //not storing in db
            });
    
        });
    })(jQuery);

    Screencast