[Resolved] Using shortcodes inside a form shortcode
This thread is resolved. Here is a description of the problem and solution.
Problem:
The issue here is that the user wanted to use a custom shortcode in the child post selection for the relationship forms.
Solution:
This is actually possible and can be done by doing the following.
[cred-relationship-form form='my-form' parent_item='$current' child_item='[my-shortcode]']
This support ticket is created 5 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.
I know what is causing the issue. It's because the view isn't generating a clean output for the value.
What you need to do is to look at the bottom of your view settings page and ensure that this option is ticket "Disable the wrapping DIV around the View "
Once you have done this the value should start working.
"Disable the wrapping DIV around the View" made my form to appear (the message "This relationship form no longer exists" disappeared). However, the child item of the form doesn't work properly. I mean, it is not populated at all.
I'll try to explain it better. I want to populate my child item with the output of the view. Currently, in my tests, this output is the ID '40'. But the shortcode :
doesn't populate the child item (now I can see the form thanks to "Disable the wrapping DIV..."). The output of the view is '40'. It can be seen in the debug mode. However, if I use the shortcode:
You can see the the form and the view here: hidden link
For your reference, this page is created with the next layout:
This is my relationship form. The item I want to populate with the output of the view is "IUsuarios".
[cred-relationship-form form='prueba-form-aceptacion' parent_item='$current' child_item='[wpv-view name="iusuario-conectado"]' ]
And here you have the output of the view alone:
[wpv-view name="iusuario-conectado"]
I switched the wordpress language to English so you can understand the debug information.
I added 1 more form. The same form but with an ID instead of a view.
The layout is:
This is my relationship form. The item I want to populate with the output of the view is "IUsuarios".
[cred-relationship-form form='prueba-form-aceptacion' parent_item='$current' child_item='[wpv-view name="iusuario-conectado"]' ]
And here you have the output of the view alone:
[wpv-view name="iusuario-conectado"]
The form with and ID instead of a view:
[cred-relationship-form form='prueba-form-aceptacion' parent_item='$current' child_item='40' ]
You can see how the item "Iusuario" is populated in the second form.
I forgot to say one important thing. As you see in the view, it shows an ID related with logged in user. This is why you see "No items found", because you are not logged in. Do you need a user?
I was trying to write a shortcode to replace the problematic one, but i'm not sure how to obtain a post ID whose author is the logged-in user. So it would be really useful to have an equivalent shortcode.