Skip Navigation

[Resolved] How to display CRED Generic checkboxes field with image as label

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

Problem:
How to display CRED Generic checkboxes field with image as label

Solution:
To display CRED generic check boxes field with dynamic option values you need to create a view that will output JSON format string that will later be used to display options of checkboxes.

You can find the proposed solution with the following reply:
=> https://toolset.com/forums/topic/cred-generic-form-checkbox-cant-get-images-to-work-for-labels/#post-562339

Relevant Documentation:
=> https://toolset.com/documentation/user-guides/inserting-generic-fields-into-forms/
=> https://toolset.com/documentation/user-guides/cred-shortcodes/#cred_generic_field

This support ticket is created 6 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 12 replies, has 2 voices.

Last updated by Timothy 6 years, 8 months ago.

Assisted by: Minesh.

Author
Posts
#561804

I've created a CRED form with a generic checkbox field that outputs a list of posts as the options. I'm using a View to create the values/labels. This works fine for outputting the post titles. But I'd like to have the labels be an image field from each post. I'm not having any luck yet. Here's my View:

<wpv-loop>[wpv-item index=1]{"value":"[wpv-post-id]","label":"<img src="[types field='element-image' size='medium' url='true' resize='crop'][/types]">"}[wpv-item index=other],{"value":"[wpv-post-id]","label":"<img src="[types field='element-image' size='medium' url='true' resize='crop'][/types]">"}</wpv-loop>

I assume the label needs to be a string, so the image is probably causing this issue. Is there another way I can get this to work?

For reference, this is the CRED content:

[credform class="cred-form cred-keep-original"]
[cred_generic_field field='TestCheckboxes2' type='checkboxes' class='' urlparam='']
{
"required":0,
"validate_format":0,
"default":[],
"options":[
[wpv-view name="website-wizard-view-1"]
]
}
[/cred_generic_field]


[cred_field field="form_submit" value="Submit" urlparam=""]
[/credform]

Tim

#561879

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

Could you please share the problem URL where you've added the above CRED form?

#561891

Sure:

goo.gl/ncaAzq

Tim

#561893

Minesh
Supporter

Languages: English (English )

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

Well - the link you shared is not working at this end.

Could you please share correct site URL.

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

#562004

Minesh
Supporter

Languages: English (English )

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

Indeed - there looks like some issue rendering checkboxes options using the view. I've reported this to our next level support.

Please hold on for further updates, I will get in touch with you as soon as possible.

#562192

Minesh
Supporter

Languages: English (English )

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

I just wanted to update you that the issue has been confirmed and our developers will soon address it. Please hold on for further updates.

#562214

Ok, thanks. But does this mean I have to wait until the next CRED plugin update or do you mean they are looking into a workaround?

Tim

#562313

Minesh
Supporter

Languages: English (English )

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

Can I have problem URL and temporary access to your site.

*** 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 would additionally need your permission to de- and re-activate Plugins and the Theme, and to change configurations on the site. This is also a reason the backup is really important. If you agree to this, please use the form fields I have enabled below to provide temporary access details (wp-admin and FTP).

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

#562339

Minesh
Supporter

Languages: English (English )

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

After debugging this too much finally I found the solution for you.

I've changed your view code as given under and now you can see image is rendered using the checkboxes:

[wpv-layout-start][wpv-items-found]<!-- wpv-loop-start --><wpv-loop>[wpv-item index=1]{"value":"[wpv-post-id]","label":"<img src=[types field='element-image' size='medium' url='true' resize='crop'][/types] >"}[wpv-item index=other] ,{"value":"[wpv-post-id]","label":"<img src=[types field='element-image' size='medium' url='true' resize='crop'][/types] >"}</wpv-loop><!-- wpv-loop-end -->[/wpv-items-found][wpv-layout-end]

Could you please check and confirm it works at your end as well.

#562342

Outstanding! It works. But what was the issue? I can't see what is the difference between your Views code and mine.

Tim

#562348

Minesh
Supporter

Languages: English (English )

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

Well - if you see your code there is mix of " " (double quotes) and '' (single quotes) used.

As you can see with the code I provided, please check how image field is rendered now, its not using "" (double quotes) with src:

"<img src=[types field='element-image' size='medium' url='true' resize='crop'][/types] >"
#562366

Minesh
Supporter

Languages: English (English )

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

I hope you spot the difference or you can try some online string comparison to check the difference between previous code and current code.

#563115

Thank you.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.