Skip Navigation

[Resolved] Problem with loading view options in generic field.

This support ticket is created 6 years, 4 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 1 reply, has 1 voice.

Last updated by s1 6 years, 4 months ago.



I am trying to:
Create a CRED form with a select-field that shows all related parents which have the same author of the post (not the parent posts of different authors).

I tried:
- JSON view inside a generic field -> returned blank (A)
- custom <option> generation via view filtered by author -> didn't save (B)
- Reading/trying all forum posts and documentation related to this problem without any good result

I expected to see:
A simple way to solve this: "show select box in cred form with parent posts that have same author"

Instead, I got:
Many hours of wasted time trying to make it work without result.

So, what I first did (A) and didn't work:

# A view "parentposts-for-author-in-json" with a filter on author:

"Select posts with the author the same as the current logged in user."

... and has this loop code:

<!-- wpv-loop-start -->
[wpv-item index=1]{"value":"[wpv-post-id]","label":"[wpv-post-title output='sanitize']"}
[wpv-item index=other],{"value":"[wpv-post-id]","label":"[wpv-post-title output='sanitize']"}  
<!-- wpv-loop-end -->

This view template returns something like this if I call it plainly (by placing [wpv-view name="parentposts-for-author-in-json"] inside a page for example):

{"value":"200","label":"Parent test 1"} ,{"value":"67","label":"Parent test 2"}

However this generic form code never generates a visible select field:

[cred_generic_field field='_wpcf_belongs_parentpost_id' type='select' class='' urlparam='']
"options":[ [wpv-view name="parentposts-for-author-in-json"] ]

After that I tried an ALTERNATIVE SOLUTION (B) also without excepted result:

In CRED form:

<select name="_wpcf_belongs_parentpost_id">
[wpv-view name="parentposts-for-author"]

In view "parentposts-for-author":

<!-- wpv-loop-start -->
  <option value="[wpv-post-id]">[wpv-post-title]</option>
<!-- wpv-loop-end -->

This showed the correct options in the CRED form but never persists to the database.

My questions:

- Why is B not working? The alternative feels more light/elegant then the JSON-way.
- If B is not possible, how can I make A work?

Thanks in advance for a quick reply!



I used this

It seems to work now.

Your marketing says "Toolset plugins let add custom types to your site and display them any way you choose – all, without writing PHP."

So it might be nice to live up to that 🙂 - display them any way you choose also means without div-wrappers and in JSON-format...

So +1 Vote to have a "Data Provider" (next to a data render) for Toolset. Which simply returns JSON (or xml or CSV-export or ...) based on filters in same great looking UI.

Now it feels 'wrong' to have to write custom PHP functions to query the same custom data for JSON output (without <div>-wrappers) while there is such a nice interface for HTML view rendering.

Thanks for taking this request serious!