Skip Navigation

[Resolved] Show dropdown in form with data from children of children

This support ticket is created 2 years, 8 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 8 replies, has 2 voices.

Last updated by michielM 2 years, 8 months ago.

Assisted by: Shane.

Author
Posts
#2328569

Continuation of my previous ticket: https://toolset.com/forums/topic/forms-generic-field-select-filled-by-view/

Shane asked me if the student would choose a location, but that's not the case. For each location the student needs to choose a Workshop. If was hoping that I could make a View with the locations and in that View all Workshops as a selection. What I don't know how to do is how to get the selection to a repeatable field of the Student type.
If there's any coding necessary, no problem, but please point me to some starting points or documentation.

I hope you can help!

#2328797

Shane
Supporter

Languages: English (English )

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

Hi Michiel,

I took another look at this at the perspective of using a view to provide the values.

How I see this working is that you have a view per set of locations.

Then on your form you will create a generic select field for each of the view that was created. Now each of the generic select fields will have the same slug as the corresponding custom field that you would want the value that is selected to be populated with.

Now you will just wrap your generic fields in conditionals based on the determining field. So if the User select A then only the generic field with the view that corresponds to A will show up.

Please let me know if this was clear as you are able to use views to provide select field values.

Thanks,
Shane

#2330263
Screenshot 2022-03-30 at 17.09.23.png

Thanks, Shane.

In the Form I have this code:

<div class="form-group">
		[cred_generic_field type='select' field='workshop']
			{
			"required":1,
			"options":[ [wpv-view name="leerling-inschrijving-lokaties-view"] ]
			}
		[/cred_generic_field]
	</div>

The field "workshop" is a field within a repeatable group of the type Student (Leerlingen).

The view has this code:

[wpv-layout-start]
	[wpv-items-found]
	<!-- wpv-loop-start -->
		<wpv-loop>
			[wpv-item index=1]
        	{"value":"[wpv-post-id]","label":"[wpv-post-title]"}
      		[wpv-item index=other]
      		,{"value":"[wpv-post-id]","label":"[wpv-post-title]"}
		</wpv-loop>
	<!-- wpv-loop-end -->
	[/wpv-items-found]
	[wpv-no-items-found]
		<strong>[wpml-string context="wpv-views"]No items found[/wpml-string]</strong>
	[/wpv-no-items-found]
[wpv-layout-end]

And I also added the filter that was mentioned in https://toolset.com/forums/topic/view-results-dont-show-on-cred-form-as-dropdown-options-but-do-show-on-page/, but I don't think it is necessary anymore.

#2330275
Screenshot 2022-03-30 at 17.28.06.png

Oh, yeah: with these settings I don't see anything on my front end form. When I edit the page where the form is placed I do see the output of the view.

#2330385

Shane
Supporter

Languages: English (English )

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

Hi Michiel,

Would you mind allowing me to have admin access to the website so that I can have a more detailed look at this for you ?

Please where applicable please provide me with a link to an example page where I can see the issue.

I've enabled the private fields for your next response.

#2331851

Shane
Supporter

Languages: English (English )

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

Hi Michiel,

Thank you for the credentials but it seems that I don't have admin permissions on this account.

Can you update the user role to admin so that I can have backend access.

Thanks,
Shane

#2333485

So sorry, I updated the user. Hope it's fine now?

#2333661

Shane
Supporter

Languages: English (English )

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

Hi Michiel,

This should be working now. I only made a few modifications.

1. I've set your view to be filtered by a URL parameter instead of shortcode attribute since you're using the url parameter parent_dagschema_id.

2. I've checked the option on your view that says "Disable the wrapping DIV around the View " so we can get a clean output from our view that will work in the select field.

3. Removed the ordered list html tags from the view.

Please let me know if this helps.
Thanks,
Shane

#2335861

Yes, it works! Thank you. Now I just have to figure out how to get children of the Location in there, but that shouldn't be a problem. And if it is, i'll create another ticket.