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);
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We demoed ACF 6.1 Beta during the most recent session of ACF Chat Fridays, highlighting the new ability to regenerate and clear labels, setting the Admin Menu Parent as a slug, and more. Catch the video replay in our latest summary. https://t.co/rHEpPVas64 pic.twitter.com/hB1XKTexXi
— Advanced Custom Fields (@wp_acf) March 23, 2023
© 2023 Advanced Custom Fields.
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.