Dear support team,
Let’s presume you’ve set up a post object field with multiple selection allowed. After selecting a single post from the dropdown – you won’t be able to select it again (It will no longer appear as an option in the dropdown).
My problem is – exactly that. Sometimes, as in my case, Custom Post Types represent items that are meant to be displayed in repetition. So if, for example, I want to use the field to represent a certain order: “Post Object A, Post Object F, Post Object Z, Post Object A (again), Post Object R”. I can’t do it.
The only alternative available for me by ACF to do so, is to create a repeater with each row containing a Post Object Field with a single selection. Now imagine the inefficiency: now I have a repeater with let’s say 20 post object fields instead of a single post object field that enables me to select 20 posts (some of them repeating) in a single field.
From my understanding the “uniqueness limitation” is controlled by acf-input.min.js (though i’m not sure – couldn’t find it) and not by the wp_query itself.
So how can I remove that “uniqueness limitation” from the post object field selection?
Thank you for a wonderful plugin,
In the end, a post object field is just a select field. In a select field each choice is only represented once and this means that each can only be selected once. In order to select the same thing multiple times it would need to exist as an option in the select field multiple times. There aren’t any ACF fields that will do this without using a repeater. This has nothing to do with the JS and has to do with the limitations of the underlying select field.
Thank you for the quick reply John.
1. There is no web-standard prevention of having the same value for multiple options in a select field – it is a common use case.
2. In the “real” end, a post object field is just an array (not a select field), no prevention for the same value repating more than once here either.
3. From my understanding (pretty sure about this), each time you begin to add an item to the post object field the wp_query re-runs. Each re-run gives all of the options regardless of what was selected before. And it is a specific JS script that forcibly removes options that were selected before.
Yes, each value could be represented in a select field multiple times, but the values need to be present in the choices multiple times in order to select them multiple times. The fact is that whether this is a select2 field that uses a bit of ajax or if it was a regular select field, the values are only present in the field one time and they are marked as selected or not selected.
I looked over the first few results and it does not appear that this is possible, even with a select2 field, but this is where you’d need to look.
ACF currently uses select2 version 3.5.2
From what I know about it, there were specific bugs in V4 of select2 that are preventing the developer from using it, not sure if those were resolved. There are also some major changes in the select2 API that need to be dealt with that are not backward compatible with V3. I do know that the current work for V5.5 still uses select2 V3, but V4 is also present in the dev version and there is a new setting in ACF that will determine which version is loaded. It’s a good question, but I don’t know the exact answer other than that it’s in the works.
Even if ACF updates to 4, there is no guarantee that the ability to choose the same value multiple times will be built into ACF. This may still be something that you’d need to add to specific fields by adding custom JS. Adding this feature would require modifications to existing fields to add a setting and as long as the fields are working for the majority of users it probably won’t be a priority.
John first of all: Thank you very much for the quick support, you helped me understand the factors of the issue.
I hope Elliot will read this thread & descide to enable selection of the same value multiple times. It can dramatically improve data editing, proccessing & loading time efficiency in some cases.
I’ve experimented with “hard replacing” the .js files of select2 in ACF with version 4 & it allows the multiple selection right out the box! But I didn’t risk saving because compatability must be made by ACF’s developer.
I have made a taxonomy with car type with two options
I select a post from (add car) and select taxonomy (sale)
But when i made a Post Object field with post of (add car) to select post that has category selected (sale) its showing empty but when i remove the taxonomy select options and select the category has whole (car type ) it shows all the posts ???
how can i fix this
You must be logged in to reply to this topic.
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!
Another heads up for next months #WPCafe. I hope you have been enjoying the monthly #WordPress chats we have been having with some great guests.— Mark Wilkinson (@wpmark) September 25, 2020
Next month is pricing WP products and services with @tom_hirst & @jackmcconnell
Watch previous episodes 👇https://t.co/IN2z2f0WSp
© 2020 Advanced Custom Fields. Subscribe