Skip Navigation

[Gelöst] Another issue with Views used as a select in a Forms

This support ticket is created vor 4 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: Asia/Hong_Kong (GMT+08:00)

Dieses Thema enthält 4 Antworten, hat 2 Stimmen.

Zuletzt aktualisiert von Pat vor 4 Jahren, 2 Monaten.

Assistiert von: Luo Yang.

Author
Artikel
#1756541

Pat

Hello,

I'm trying to use a Views as a select generic field inside a forms.
I'm already made 2 other tests that was working fine and I'm trying a third one and cannot display the select. For info, I have used the same structure than the 2 first.
Here is the Views :


and my generic field inside the Forms :

[cred_generic_field type='select' field='wpcf-id-du-produit-achete']
{
"required":1,
"persist":1,
"options":[ [wpv-view name="backoffice-select-conference"]  ]
}
[/cred_generic_field]

If I put the Views inside a post, here is what I'm getting :

{"value":"12284","label":"Conférence – Où est le sens – 04-06-2021 – 2020"},{"value":"12283","label":"Conférence – Peut-on vraiment changer – 22-04-2021 – 2020"} ,{"value":"12282","label":"Conférence – L'avenir de la famille – 20-03-2021 – 2020"} ,{"value":"12281","label":"Conférence – La passion de la France – 05-02-2021 – 2020"} ,{"value":"12280","label":"Conférence – Une philosophique de la société – 22-01-2021 – 2020"} ,{"value":"12279","label":"Conférence – L'éloge de l'énergie vagabonde – 13-11-2020 – 2020"} ,{"value":"12258","label":"Conférence – Une observatrice dans les coulisses du pouvoir – 15-10-2020 – 2020"} 

If I replace the shortcode by the Views result in the generic field, then, everything is fine.
All Views are related to products. Other point, if I replace the post title inside the Views by the post ID, then, this is working.
Could it be that some specific caracters inside the product name could be the issue and if yes, which type of caracter?
Any idea why this specific Forms is not working?
Last point, I have a hook to enable the use of a Views inside a form.

Regards
Pat

#1757457

Dear Pat,

It should be a problem of special character, in the codes you mentioned above, there are two option titles are using single quote:

- Conférence – L'avenir de la famille – 20-03-2021 – 2020
- Conférence – L'éloge de l'énergie vagabonde – 13-11-2020 – 2020

Please try to edit those two posts, remove the single quote, and test again

#1757581

Pat

Hi Luo,

Thanks for helping.
Just tried to make the proposed changes and this is not working.
Here is the new Views result :
{"value":"12284","label":"Conférence – Où est le sens – 04-06-2021 – 2020"},{"value":"12283","label":"Conférence – Peut-on vraiment changer – 22-04-2021 – 2020"} ,{"value":"12282","label":"Conférence – L avenir de la famille – 20-03-2021 – 2020"} ,{"value":"12281","label":"Conférence – La passion de la France – 05-02-2021 – 2020"} ,{"value":"12280","label":"Conférence – Une philosophique de la société – 22-01-2021 – 2020"} ,{"value":"12279","label":"Conférence – L éloge de l énergie vagabonde – 13-11-2020 – 2020"} ,{"value":"12258","label":"Conférence – Une observatrice dans les coulisses du pouvoir – 15-10-2020 – 2020"}

Just for info, as mentioned in my first post, if I replace the shortcode by the Views result inside the generic field, this is working fine (even with the special caracters !). It sounds that this is more related to the shortcode management inside the generic field?

I have also 2 other Forms that are using the same kind of generic field with Views (also linked to products) as select and they are working fine. I have tried to place a special caracter in one of the title and this is stil working fine. Here is the result one one of the Views :
{"value":"12301","label":"Sortie – MENTON : JARDIN SERRE DE L’A MADONE – 15-04-2021 – 2020-€"},{"value":"12224","label":"Sortie – BIOT : LE MAQUIS ET LA GÉOLOGIE DU DÔME VOLCANIQUE – 18-03-2021 – 2020-€"} ,{"value":"12221","label":"Sortie – AUTOUR DE SIX-FOURS : ART, JARDIN ET SCULPTURES – 03-12-2020 – 2020-39€"} ,{"value":"12149","label":"Sortie – LES MUSÉES DE TOURRETTE-LEVENS – 05-11-2020 – 2020-€"} ,{"value":"12146","label":"Sortie – QUINSON/GANAGOBIE – 08-10-2020 – 2020-€"}

Last info, I'm using a hook for using a Views inside a Cred :

add_filter( 'wpv_filter_wpv_view_shortcode_output', 'prefix_clean_view_output', 5, 2 );
  
function prefix_clean_view_output( $out, $id ) {
if (( $id == '5880' ) OR ( $id == '6152' )OR ( $id == '6184' )) 
{ 
$start = strpos( $out, '<!-- wpv-loop-start -->' );
if ( 
$start !== false
&& strrpos( $out, '<!-- wpv-loop-end -->', $start ) !== false
) {
$start = $start + strlen( '<!-- wpv-loop-start -->' );
$out = substr( $out, $start );
$end = strrpos( $out, '<!-- wpv-loop-end -->' );
$out = substr( $out, 0, $end );
}
}
return $out;
} 

Any idea?
Regards
Pat

#1757621

I suggest you try the normal debug steps?
1) Make sure you are using the latest version of Toolset plugins, you can download them here:
https://toolset.com/account/downloads/

2) In case it is a compatibility problem, please deactivate all other plugins, and switch to wordpress default theme 2020, deactivate all custom PHP/JS code snippets, and test again

3) Also check if there is any PHP/JS error in your website:
https://toolset.com/documentation/programmer-reference/debugging-sites-built-with-toolset/

4) If the problem still persists, please provide database dump file(ZIP file) of your website, you can put the package files in your own google drive disk, share the link only, also point out the problem page URL and form URL, I need to test and debug it in my localhost, thanks
https://toolset.com/faq/provide-supporters-copy-site/

#1759525

Pat

Hi Luo,

Thanks for your help. It seems that the issue was related to the sorting parameter of the Views.
Regards
Pat