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>
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
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]"}
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.