Skip Navigation

[Resolved] Limiting repeatable group depending on a select value in the group

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 5 replies, has 3 voices.

Last updated by Minesh 7 months, 3 weeks ago.

Assisted by: Minesh.

Author
Posts
#2689898

Hi

I have a CPT with a Repeatable group.
There is a bunch of fields inside it but one of them is a selecting field containing "Version 1", "Version 2", "Version 3".

I need to be able to enter only once each version.

Is it possible to apply that limit ?

#2689939

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

That sounds tricky.

Let me make sure I've understood what you are asking.

If your CPT has a repeatable field group, when editing a post you can add multiple groups of fields.

One of the fields in the group in your case is a select field with 3 options.

And you requirement is that if an option has already been selected in a previous group, it should not be possible to select it again in another group, yes?

Is the data being entered in the back-end edit screens or with a front-end form?

Any solution will certainly involve custom code, but if you can confirm the above, we might be able to give you some pointers as to how you might go about it.

#2690040

Hi Nigel.

I'll finally work with 3 relationships.
So to explain more clearly I have a CPT "Movie", and a CPT "Versions"
I've made 3 relationships between both : Version1, Version2 and Version3 relationships (1 to 1).

On the page of a movie I need to display content1 if "Version1" relationship exists (so I need to use conditional display to check the existence of the relationship between this "movie" and "Version1"). How can I achieve that ?

If the relationship does not exist I'd like to display button to add the relationship AND create the Version post at the same time. Do you understand what I'm trying to do ?

#2690262

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

It seems you forget to answer the following question.
- Is the data being entered in the back-end edit screens or with a front-end form?

#2690465

Hi Minesh

Data will be entered front-end.

#2690466

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

You can use the "cred_form_validate" hook to validate the form entry and selection.
- https://toolset.com/documentation/programmer-reference/cred-api/#cred_form_validate

If you can share the details where you added your form and test steps about how exactly you want to validate the form - I will review and check what would be the best possible option.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.