Is there a way to duplicate a flex field ? (Front-end in wp-admin).
Any plugin available? I tried doing it with javascript but it´s gets pretty messy, and the wysiwyg, time picker, and the other javascript based fields needs to reload..
function cloneMe(obj) {
var layout = obj.closest('.layout'),
cloner = layout.clone(true),
values = layout.closest('.values'),
column_num = Math.floor((Math.random() * 1000000) + 1);
cloner.attr('data-id', column_num);
cloner.find('[name^="acf[field_"]').each(function() {
var field_name = $(this).attr('name');
var index_location = field_name.indexOf(']')+2;
var new_name = field_name.substr(0, index_location) + column_num + field_name.substr(index_location+1)
$(this).attr('name', new_name);
});
cloner.appendTo(values);
}
None that I’m aware of.
If I was going to try to do something like this I would…
1) get the entire inner HTML of the layout
2) generate a new uniqid for a new layout and then somehow insert the entire layout into the page
3) get all of the fields that might be in the layout by looking for “data-key” and “data-type” values
4) trigger some kind of event on each new field to make ACF refresh it
Like you said, it’s pretty messy and would take a lot of work just figuring out what events to trigger. I think that if someone were to create something like this there’d be a lot of people willing to pay for it.