WPIntell

Source evidence

Uniqueness to Relation field

Advanced Custom Fields: Validated Field · support · 2015-10-08T18:42:00+00:00

complaintsentiment
mediumseverity
0.86relevance
4replies
Evidence linked to opportunitycommercial context

Proof Health

Open evidence

Commercial opportunities need traceable source links before they are treated as build-worthy.

5 / 31 rows with source links

16.1% of this page's analysis has direct source links.

0 build-decision rows missing links

0 rows here require auditable proof before promotion.

26 rows with no attached evidence

0 rows have source counts but still need direct links.

Conversation

support
leonardo_ndo unresolved
Hello! I could not use the uniqueness for a Relation field! Is this possible and how can i achieve it? https://wordpress.org/plugins/validated-field-for-acf/ Hi @leonardo_ndo , Is it not working for any of the unique settings or one in particular? Can you let me know what version of ACF, Validated Field, and WordPress you are using? Thanks! Hello, thanks for the quick answer. I’ve tried all the unique options, none of them works. It shows me the error, even if there is no posts inserted. Versions ACF: 4.4.3 VF: 1.7.7 WP: 4.3.1 Thanks in advance Unfortunately this isn’t working correctly in the current version of the plugin, but I am working on version 2.0 that will handle this much differently. The issue is that the relationship field values are stored as an array of post IDs which is then serialized before it’s saved to the postmeta table. To make things trickier, you can resort the selected values if more than one is allowed which resulted in some funky LIKE statements to try and detect dupes. The new version will hook into the field update and save the individual IDs to their own meta keys, along with a sorted array which we can rely on to determine uniqueness. Couple that with repeater fields and the new support for User and Option meta fields, and the code that generates the SQL statements has gotten a little crazy. Nearly 500 lines :/ The latest code can be found here https://github.com/doublesharp/validated-field-for-acf , but note that it is still a little buggy (and I haven’t checked in the new relationship code, should have that in a few hours). I’ll wait for a stable version then. Thank you very much

Comments

4 shown
doublesharp 2015-10-08T19:08:00+00:00

Hi @leonardo_ndo , Is it not working for any of the unique settings or one in particular? Can you let me know what version of ACF, Validated Field, and WordPress you are using? Thanks!

leonardo_ndo 2015-10-08T19:13:00+00:00

Hello, thanks for the quick answer. I’ve tried all the unique options, none of them works. It shows me the error, even if there is no posts inserted. Versions ACF: 4.4.3 VF: 1.7.7 WP: 4.3.1 Thanks in advance

doublesharp 2015-10-09T00:28:00+00:00

Unfortunately this isn’t working correctly in the current version of the plugin, but I am working on version 2.0 that will handle this much differently. The issue is that the relationship field values are stored as an array of post IDs which is then serialized before it’s saved to the postmeta table. To make things trickier, you can resort the selected values if more than one is allowed which resulted in some funky LIKE statements to try and detect dupes. The new version will hook into the field update and save the individual IDs to their own meta keys, along with a sorted array which we can rely on to determine uniqueness. Couple that with repeater fields and the new support for User and Option meta fields, and the code that generates the SQL statements has gotten a little crazy. Nearly 500 lines :/ The latest code can be found here https://github.com/doublesharp/validated-field-for-acf , but note that it is still a little buggy (and I haven’t checked in the new relationship code, should have that in a few hours).

leonardo_ndo 2015-10-09T11:45:00+00:00

I’ll wait for a stable version then. Thank you very much