Skip Navigation

[Resolved] Generic select form field from repeatable field group, one-to-many relationship

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/Karachi (GMT+05:00)

Author
Posts
#2658799
Screenshot 2023-10-31 at 08-53-49 test job – pdb ICM staging.png
Screenshot 2023-10-31 at 08-18-37 Edit View ‹ pdb ICM staging — WordPress.png
Screenshot 2023-10-31 at 08-15-19 Edit View ‹ pdb ICM staging — WordPress.png
Screenshot 2023-10-31 at 06-26-23 Edit Client’s Jobs ( 1 m ) - Relationships ‹ pdb ICM staging — WordPress.png
Screenshot 2023-10-31 at 06-35-03 Edit Client “Midvale Office of Public Health ” ‹ pdb ICM staging — WordPress.png

I need a selection field that gives as options repeatable field group items from a parent post (‘Client’) in a one-to-many relationship to the post (‘Job’) where the form will appear.

What I’m trying relies on two views queries: one to generate the list of repeatable field group items, filtered by relationship to the parent post, and the other (which I’m calling ‘container’) to relate the child post where the form is shown to the parent. This query-inside-a-query approach does output the intended filtered list when the ‘container’ view is displayed in a content template for the child post. But it does not produce a selection field successfully.

This is what’s in my test form:

<h4>Job Edit Test Form</h4>

<div class="form-group">
	[cred_field field='@clients-and-jobs.parent' class='form-control' output='bootstrap' select_text='--- not set ---' required='false']
</div>

<div class="form-group">
	<label for="%%FORM_ID%%_job-primary-contact">[cred_i18n name='job-primary-contact-label']Job Contact Selection Test[/cred_i18n]</label>
	[cred_generic_field type='select' field='wpcf-job-primary-contact']
	{
	"required":0,
	"options":[ [wpv-view name='job-contacts-selection-container'] ],
	"persist":1
	}
	[/cred_generic_field]
</div>

[cred_field field='form_submit' output='bootstrap' value='Submit' class='btn btn-primary btn-lg']

<p>contacts list: [wpv-view name="job-contacts-selection-container"]</p>

This is the content template:

<div style="margin-bottom: 3em; padding: 1.5em; border: 1px solid #bbb; border-radius: 1em;">
	[cred_form form='job-set-edit-form']
</div>

<p>RFG contacts for Client parent: [wpv-view name="job-contacts-selection-container"]</p>

The page output, list view, container view, relationship, and RFG for the parent are attached as screenshots.

Just for clarity, here’s the code from the list view that my screenshot tool obscures:

<wpv-loop>
	[wpv-item index=other]
		{'value':'[types field="client_contact_name"][/types]','label':'[types field="client_contact_name"][/types]'},
	[wpv-item index=last]
		{'value':'[types field="client_contact_name"][/types]','label':'[types field="client_contact_name"][/types]'}
</wpv-loop>
#2659025

Hi,

Thank you for contacting us and I'd be happy to assist.

From the screenshots, the set up looks correct. But I'll need to see exactly how these elements are set up in the admin area for troubleshooting.

Can you please share temporary admin login details, along with the page where this form can be seen?

Note: Your next reply will be private and making a complete backup copy is recommended before sharing the access details.

regards,
Waqar

#2659531

Thank you for sharing the access details.

I've made the following changes and the generic field is working now.

1. The output of the view 'job contacts selection container' was adding lot of extra empty space, at the start and the end.

To fix this, I removed the '[wpv-filter-meta-html]' tag from its 'Output Editor' section and removed the line breaks and empty spaces from its 'Loop Editor' section.

2. In the form 'job set-edit form', replaced the single-quotes with the double-quotes in the view's shortcode used in the generic field's code:


"options":[ [wpv-view name="job-contacts-selection-container"] ],

3. Lastly, replaced the single-quotes with the double-quotes, in the option's output from the view 'job contacts JSON selection list':


[wpv-item index=other]
{"value":"[types field='client_contact_name'][/types]","label":"[types field='client_contact_name'][/types]"},
[wpv-item index=last]
{"value":"[types field='client_contact_name'][/types]","label":"[types field='client_contact_name'][/types]"}

#2660059

Thank you, Waqar. This is instructive, very helpful. I’d had a sense that quote-marks nesting was part of my problem, but without the picture of the working parts together that you’ve provided here, my attempts in that way weren’t making a difference.