I want to be able to drag and drop a list of custom items in any order, similar to the WordPress navigation menu interface but instead of menu items each of my items simply needs to be uneditable text which I will define. The ideal scenario would be the following:
Image of what it may look like:
Notice that:
If anyone has insight on how I may accomplish this either using the setup I proposed or perhaps using a different setup that may be more efficient I’d appreciate any input.
Thank you!
Hi @cfxd
Thanks for the question.
I’m sure this will be possible by hooking into the acf/prepare_field
filter and modifying the sub field’s value / disbaled settings.
Something like this should work:
$GLOBALS['acf_item_count'] = 0;
function acf_prepare_field_item( $field ) {
// set disabled
$field['disabled'] = 1;
// set value
if( empty($field['value']) ) {
// incease count
$GLOBALS['acf_item_count']++;
// set value
$field['value'] = $GLOBALS['acf_item_count'];
}
// return
return $field;
}
add_filter('acf/prepare_field/key=field_5600966e8fad1', 'acf_prepare_field_item', 10, 1);
The only issue is that by setting a select field to ‘disabled’, it won’t save it’s value… perhaps instead, you will need to change the $field['class']
to ‘disabled’, and then add some CSS / JS to prevent the select field from being clicked / changed.
Good luck
I’m kind of interested in hearing how this worked?
It seems to me no add-ons work with the newest, and I’d like to customize my repeater field to be more mobile-friendly, which this looks like it would be 🙂
-Magnus
I compromised the feature that this logic was part of. If you figure out a way to get this working smoothly though please let us know!
The topic ‘Allow admin to sort a list using Repeater field’ is closed to new replies.
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 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 Privacy Policy. If you continue to use this site, you consent to our use of cookies.