Skip Navigation

[Gelöst] Using view with custom attribute as an option for generic select field

Dieser Thread wurde gelöst. Hier ist eine Beschreibung des Problems und der Lösung.

Problem:
The user was using a view to generate values for a generic field. The view was crashing the field.

Solution:
It turns out that the user was nested shortcodes and used inside the generic field shortcode. This is 3 level of nested shortcodes, which is not possible. We can only nest 2 levels of shortcodes. To workaround it, you can replace the nested shortcodes by a custom shortcode that hides one level of nesting. Check the example here https://toolset.com/forums/topic/using-view-with-custom-attribute-as-an-option-for-generic-select-field/page/2/#post-2181729

This support ticket is created vor 3 Jahren, 2 Monaten. 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.

Heute stehen keine Supporter zur Arbeit im Werkzeugsatz-Forum zur Verfügung. Sie können gern Tickets erstellen, die wir bearbeiten werden, sobald wir online sind. Vielen Dank für Ihr Verständnis.

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: Africa/Casablanca (GMT+01:00)

Author
Artikel
#2181729

Well, the issue as Christian has suggested earlier comes from the too many nested levels of shortcodes: A view shortcode inside another view shortcode, which is inside the generic field shortcode.
https://toolset.com/forums/topic/using-view-with-custom-attribute-as-an-option-for-generic-select-field/#post-2177971

I created a shortcode for the "Principal Investigator" field and it fixed the view. I added it here versteckter Link

add_shortcode('json-principal-investigator', function(){
  return wpv_do_shortcode('[wpv-view name="principal-investigators-pi-as-options-for-post-a-trial" instpostid="[current_user_member_institution_post_id]"]');
});

And I used it in the generic field:

<div class="field-wrap">
		<label for="%%FORM_ID%%_trial-pi" class="InstHeader">[cred_i18n name='trial-pi-label']Principal Investigator (PI)[/cred_i18n]</label>
      	[cred_generic_field type='select' field='generic-principal-investigator-select']
          {
          "required":1,
          "default":"",
          "options":[ [json-principal-investigator] ]
          }
        [/cred_generic_field]
	</div>

This shortcode uses our wpv_do_shortcode that is used by Toolset and that is able to handle 1 level of nested shortcodes.

Does it make sense? Let me know your feedback.

#2181999

This is great!
I thought that one view as an attribute inside another view is ok and 1+ view is not ok. But now I know. Thank you for your help. My issue is resolved now.