Skip Navigation

[Resolved] Create Cascading Dropdown

This support ticket is created 5 years, 5 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 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9: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/Hong_Kong (GMT+08:00)

This topic contains 1 reply, has 2 voices.

Last updated by Luo Yang 5 years, 5 months ago.

Assisted by: Luo Yang.

Author
Posts
#1293265
2019-07-16_23-37-16.png

Hello,

I am working on a Site based on Toolset Reference Site 'Real Estate'

I have 3 CPTs to define the location of a House:

  • States
  • Municipalities, and
  • Zones

All relationtionships have been created accordingly.

I have created a CRED Form called 'Add House':

In the CRED form I have added 3 control-forms to select the State, Municipality and Zone where the 'House' belongs.

What I need now is to cascade the dropdown:

  • When a user selects a 'State', I need to filter the next dropdown ('Municipalities') to display only municipality values belonging to that 'State'
  • After the user selects the 'Municipality' I need to filter the next dropdown ('Zones') to display only zones values belonging to that 'Municipality'.

How could I achieve this result, creating a Cascading Dropdown?

	<div class="form-group">
		<label>[wpml-string context='cred-form-Add House-356' name='State Parent']State[/wpml-string]</label>
		[cred_field field='@state-house.parent' class='form-control' output='bootstrap' select_text='--- not set ---']
	</div>

	<div class="form-group">
		<label>[wpml-string context='cred-form-Add House-356' name='Muni Parent']Muninicipality[/wpml-string]</label>
		[cred_field field='@municipality-house.parent' class='form-control' output='bootstrap' select_text='--- not set ---']
	</div>

	<div class="form-group">
		<label>[wpml-string context='cred-form-Add House-356' name='Zone Parent']Zone[/wpml-string]</label>
		[cred_field field='@zone-house.parent' class='form-control' output='bootstrap' select_text='--- not set ---']
	</div>
#1293327

Hello,

There isn't such kind of built-in feature within Toolset Forms plugin.

As a workaround, you can try these:
1) create a page, setup a post view, list all "Zones" posts, and filter by the post type relationship (cascade dropdown):
https://toolset.com/documentation/post-relationships/how-to-display-related-posts-with-toolset/how-to-filter-posts-by-their-ancestors/

2) in above view's loop, follow our document to display the child 'Add House' form link:
https://toolset.com/documentation/post-relationships/selecting-parent-posts-using-forms-create-child-items/

For your reference.