Skip Navigation

[Resolved] Some issues with Cred generic field options with Views shortcode

This thread is resolved. Here is a description of the problem and solution.

Problem:
Some issues with Cred generic field options with Views shortcode - double quote with generic field option value not working

Solution:
You need to escape the quotes. So to add the string with quotes you should use as given under:

{"value":"Cours \"bellissima\" 2018","Cours \"bellissima\" 2018":""}

You can find the proposed solution in this case with the following reply:
https://toolset.com/forums/topic/some-issues-with-cred-generic-field-options-with-views-shortcode/#post-1246518

Relevant Documentation:
https://toolset.com/documentation/user-guides/inserting-generic-fields-into-forms/

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

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

This topic contains 4 replies, has 2 voices.

Last updated by Pat 5 years, 7 months ago.

Assisted by: Minesh.

Author
Posts
#1246089

Pat

Hello,

I'm using a Cred generic field and have created a Views in order to populate the options. The Views result is fine and I have been able to verify that this is inline with the options rules.

Now, I'm facing 2 issues :

1. I cannot define a default option in the generic field. If I place a Views field, it is not taken into consideration.
2. If there is a " inside the text that is returned by the Views, then the generic field does not display. This point is critical when you use front end inputs to populate the Views ! (ie : when the Views list the title of the posts created by users).

Regards
Pat

#1246430

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

1. I cannot define a default option in the generic field. If I place a Views field, it is not taken into consideration.
=> Can you please share the generic field you code you are using?

2. If there is a " inside the text that is returned by the Views, then the generic field does not display. This point is critical when you use front end inputs to populate the Views ! (ie : when the Views list the title of the posts created by users).
=> I think you need to parse the value while you are generating as JSON before you pass to the generic field. Can I have problem URL and access details?

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#1246468

Pat

Hi Minesh,

Sorry but it's not possible for the moment to give you access. Here is some complementary info :

1. Generic field code. It is used in a Cred modification to retrieve a field from the post and give the oportunity to chose another product (the Views shortcode gives the list of potential products).

[cred_generic_field type='select' field='wpcf-nom-de-l-evenement']
{
"required":0,
"default":"[types field='nom-de-l-evenement'][/types]",
"options":[[wpv-view name="backoffice-select-enseignement"]]
}
[/cred_generic_field]

2. Result of the shortcode when using " character :
{"value":"Cours "bellissima" 2018","Cours "bellissima" 2018":""}
This is blocking the display of the generic field

Regards
Pat

#1246518

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Well - It seems both issues works for me.

1. Generic field code. It is used in a Cred modification to retrieve a field from the post and give the oportunity to chose another product (the Views shortcode gives the list of potential products).
==> As you can see, I've added types shortcode with the specific post ID to get value from and I see the option is set selected.
[cred_generic_field type='select' field='test-select-field']
{
"required":0,
"default":"[types field='property-bathrooms' item='1591'][/types]",
"options":[{"value":"1","label":"one"},{"value":"2","label":"two \"bellissima\" 2 "},{"value":"3","label":"three"}]
}
[/cred_generic_field]

2. Result of the shortcode when using " character :
{"value":"Cours "bellissima" 2018","Cours "bellissima" 2018":""}
==> Again, you need to escape the quotes. So to add the string with quotes you should use as given under:

{"value":"Cours \"bellissima\" 2018","Cours \"bellissima\" 2018":""}

You can check here how JSON string escape work.
=> hidden link

#1271523

Pat

Hi Minesh,

Thanks for the info.
I'm not able to use it as you propose as this is a front-end submission and I can't control what the user will use as title.
I will setup a cred_save_data in order to re-write the title and delete the unwanted signs.
Regards
Pat