Skip Navigation

[Resolved] Generic select field using options from types checked checkboxes

This support ticket is created 3 years, 2 months ago. There's a good chance that you are reading advice that it now obsolete.

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
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 7 replies, has 2 voices.

Last updated by adamG-6 3 years, 2 months ago.

Assisted by: Shane.

Author
Posts
#2186741

Tell us what you are trying to do?

I have post type called "Jobs". In this post the recruiter user will have to choose advertising media options from a list of checkboxes - custom field called "advertising-media".

I have a candidate form called "application". The candidate user will need to select one of the checked options.

I understand that I need to add a generic select field with a shortcode of the checked "advertising-media" options. However, I do not know how to create this shortcode.

The "application" form will appears on the same "job" post so the post ID will need to the one of the current page.

hidden link

#2186991

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Adam,

Thank you for getting in touch.

I have a candidate form called "application". The candidate user will need to select one of the checked options.

Which select option are you referring to ? As the Job would've already have the "advertising-media" field checked already with an option.

I understand that I need to add a generic select field with a shortcode of the checked "advertising-media" options. However, I do not know how to create this shortcode.

Is it that you want to add the Advertising Media checkbox value to the application form ? Not sure what you are referring to here.

Can you perhaps clarify here for me as i'm not understanding the request in this ticket fully.

Thanks,
Shane

#2187033

Hi Shane,

Thank for looking into this.

I have:
• Two custom post types: Job and Application
• Two user types: Recruiter and Candidate

When a Recruiter creates a Job they have to check the various media that will be used to advertise the job externally elsewhere e.g.

Media A
Media B
Media C
Media D
Media E

If for instances Recruiter choses Media A, B and E from the checkboxes, I want Candidate to select only one - i.e. where they saw the job advertised.

Application forms (Post form) will appears on the Job post.

In the Application Post cred form I want to use a generic select field using options dynamically posted via the the checked checkboxes. I believe dynamic options require a shortcode:

[cred_generic_field type='select' field='slug']
{
"required":0,
"options":[ [shortcode] ]
}
[/cred_generic_field]

#2187217

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Adam,

We are going to run into some issues here.

Firstly the dynamic options are usually populated by a view and this view will be bringing in Post Data.

It would appear that the data that you want to add won't be any form of post data but some dynamically generated list that you have in mind.

What would this dynamic data consist of and where would it be coming from? From there I would be able to say whether this is something that is achievable

Thanks,
Shane

#2187237

Hi Shane,

The "Jobs" custom post has a types field called: [types field='advertising-media' separator=', '][/types]

This is an example live job post: hidden link

This particular post has Guardian, LinkedIn, Reed.co.uk selected as the advertising media. I Have edited the template to include "Dynamic list of Advertising Media" on the front end showing the selected options, before the "Application" form.

In this instance I would like the Candidate to choose only one of Guardian, LinkedIn, Reed.co.uk.

#2187255

Alternatively I could change the custom field group "Advertising Media" to a repeatable select group. Would that make it easier? How easy is it to create JSON output of a repeatable group?

#2187911

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Adam,

I understand what you're trying to achieve now, however if you're going to do this you will perhaps need to write a custom shortcode that would render the [types field='advertising-media' separator=', '][/types] field as a JSON output.

Alternatively I could change the custom field group "Advertising Media" to a repeatable select group.Would that make it easier? How easy is it to create JSON output of a repeatable group?

This is possible as you're able to create a JSON output using views and the repeatable field groups. In this case your view should be formatted like this.

<wpv-loop>
			[wpv-item index=other]
				{"value":"[wpv-post-id]","label":"[wpv-post-title]"},
			[wpv-item index=last]
				{"value":"[wpv-post-id]","label":"[wpv-post-title]"}
		</wpv-loop>

Also ensure that the "Disable the wrapping DIV around the View" checkbox is checked.

Thanks,
Shane

#2193235

My issue is resolved now. Thank you!