Skip Navigation

[Resolved] JSON view output in Generic Field not working.

This support ticket is created 3 years, 11 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.

This topic contains 4 replies, has 3 voices.

Last updated by shaunV 3 years, 11 months ago.

Author
Posts
#1883357

Hey there, small issue with populating a Generic CRED field with JSON output for a view.

(could be related to this? https://toolset.com/errata/using-a-view-with-json-output-to-populate-generic-select-field-in-a-form-not-working/ )

This was working fine and then just stopped.

CRED Form:

[cred_generic_field type='multiselect' field='article-tags' class="article-tagging"]
{
"required":1,
"default":[],
"options":[[wpv-view name='article-tags-options' cached='off']]
}
[/cred_generic_field]

View: (div wraping disabled)

[wpv-layout-start]
[wpv-items-found]
<!-- wpv-loop-start -->
<wpv-loop>[wpv-item index=1]{"value":"[wpv-taxonomy-slug]","label":"[wpv-taxonomy-title output="sanitize"]"}[wpv-item index=other],{"value":"[wpv-taxonomy-slug]","label":"[wpv-taxonomy-title output="sanitize"]"}</wpv-loop>
<!-- wpv-loop-end -->
[/wpv-items-found]
[wpv-layout-end]

---
If you output the views json directly and then copy paste it in to the field it works just fine.

Here is a (shortend) view oputput whne placed directly on the form page to examine the output.

{“value”:”team-building”,”label”:”Team Building”},{“value”:”themes”,”label”:”Themes”},{“value”:”tinciture”,”label”:”Tinciture”},{“value”:”to-do-com”,”label”:”To Do com”},{“value”:”tools”,”label”:”Tools”},{“value”:”toolset”,”label”:”Toolset”},{“value”:”validation”,”label”:”Validation”},{“value”:”video”,”label”:”Video”},{“value”:”video-recording”,”label”:”Video Recording”},{“value”:”webcam”,”label”:”Webcam”},{“value”:”webinar”,”label”:”Webinar”},{“value”:”wordpress”,”label”:”Wordpress”},{“value”:”youtube”,”label”:”YouTube”}

not sure whats going on, I am using Blocks, and not legacy Views.

#1883359

Cred Form ID: 10054 (form for selecting the options)

View ID: 10140 (outputs the JSON)

#1884091

Nigel
Supporter

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

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

I think when you use the UI to insert the generic field with the View shortcode, it will include spaces between the square brackets, and those are missing in your example above.

Specifically this line, can you add spaces, like so:

"options":[ [wpv-view name='article-tags-options' cached='off'] ]

I seem to recall that being the culprit previously, but in any case, if you are not editing the form in expert mode then if you use the GUI to insert the generic field and add the wpv-view shortcode in the options, it should generate the markup and shortcodes correctly.

(I understand from others that this may have stopped working, possibly because of some code optimisation, but please try the above.)

#1884349

Thanks Nigel ... wow, that was it... I tried so many things to get this to work.

Merry Xmas mate, have a good holiday!

Stuart

#1887685

Hi Nigel, I cannot get this to work. It use to work with the patch, but after the updated I doesn't work anymore.
Shall I open a new post?