Skip Navigation

[Resolved] I need to create a select field with a list of post

This support ticket is created 4 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.

Our next available supporter will start replying to tickets in about 1.60 hours from now. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

This topic contains 2 replies, has 2 voices.

Last updated by aldoR 4 years, 2 months ago.

Assisted by: Nigel.

Author
Posts
#1437679

I'm creating a listing site where customer can insert listing with cred module
I have 2 post type "aziende" and "annunci", when creating a new "annunci", the user should be able to choose a field with the various posts of the "aziende" post type

in post type custom field of "annunci" It is possible to insert a select field with the list of posts "aziende"?

many thanks
Aldo

#1437723

Nigel
Supporter

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

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

Screenshot 2020-01-03 at 10.02.44.png

For this you can add a generic select field to your form, and then populate the select options with the output of a View.

If you add a generic select field to a form with a few dummy options, you can see the format required for your View output, e.g.

[cred_generic_field type='select' field='wpcf-some-field']
{
"required":0,
"default":[],
"options":[{"value":"one","label":"Label One"},{"value":"two","label":"Label Two"},{"value":"three","label":"Label Three"}]
}
[/cred_generic_field]

That's from the expert mode where you can see the shortcodes. If you want to save the value of this select field you'll need to use expert mode so that you can add the "persist": 1 parameter to the above, which isn't available in the GUI.

Create the View to display the posts. You can use the "List with separators" output format in the Loop Wizard to help generate the required markup that automatically disables the wrapper div (screenshot), which you will in any case need to edit manually so that you end up with something like this:

[wpv-layout-start]
	[wpv-items-found]
	<!-- wpv-loop-start -->
		<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>
	<!-- wpv-loop-end -->
	[/wpv-items-found]
	[wpv-no-items-found][/wpv-no-items-found]
[wpv-layout-end]

You can then edit your form and in the GUI insert the wpv-view shortcode for this View to provide the options, or, if using expert mode so that you can add the persist option, use the wpv-view shortcode as per my example below:

[cred_generic_field type='select' field='wpcf-some-field']
{
"required":0,
"options":[ [wpv-view name="Form options"] ],
"persist":1
}
[/cred_generic_field]
#1438857

My issue is resolved now. Thank you!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.