Skip Navigation

[Resuelto] Checkbox fields not returning the names, instead they are returning 1,1,1,

Este hilo está resuelto. Aquí tiene una descripción del problema y la solución.

Problem: I would like to show the names of selected checkboxes in a checkboxes group custom field, but the values are showing instead.

Solution: By design, the checkboxes field outputs the value of each selected checkbox. In order to display some other text, remove the current types field shortcode and insert it again. In the configuration popup, you will have the ability to choose custom text to display for each checked and unchecked checkbox.

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.

Our next available supporter will start replying to tickets in about 1.09 hours from now. Thank you for your understanding.

Etiquetado: 

This topic contains 6 respuestas, has 2 mensajes.

Last updated by Christian Cox hace 3 años, 3 meses.

Assigned support staff: Christian Cox.

Autor
Mensajes
#923447

Checkbox fields not retuning the names on the view archive or singular, instead they are returning 1,1,1,

it was working before I updated the plugins today, it should display the names of the checkbox fields.

hidden link

#923689

Hi, can you share the actual shortcodes you are using to insert the checkbox fields in the page? I will review them here and try to figure out what's happening.

#923878
Screenshot (1)_ Shortcode.png

Hi Christian

This is the shortcode for the accreditations checkboxes that I am inserting into the page/content template:

[types field='accredditations-test' separator=', '][/types]

Please also see attached screenshot (1) to see the shortcode I have put in the text editor. Screenshot (2) shows how the values on the front end are only displaying numbers (", , 1,, etc.) instead of actual values.

Thanks

#924209
Screen Shot 2018-07-12 at 11.22.36 AM.png

Okay thanks. By design, the checkboxes field outputs the value of each selected checkbox. In order to display some other text, remove the current types field shortcode and insert it again. In the configuration popup, you will have the ability to choose custom text to display for each checked and unchecked checkbox. I'm attaching a screenshot here that shows how this looks.

You'll end up with a series of shortcodes similar to this:

[types field='cbs-after' option='0' state='checked']CB1[/types][types field='cbs-after' option='0' state='unchecked']Not CB1[/types][types field='cbs-after' option='1' state='checked']CB2[/types][types field='cbs-after' option='1' state='unchecked']Not CB2[/types][types field='cbs-after' option='2' state='checked']CB3[/types][types field='cbs-after' option='2' state='unchecked']Not CB3[/types]
#924447
Front End.png
Correct values on Front end.png
Not Selected left blank.png
Not Selected.png

Hi Christian

Thanks for your reply.

I have followed your instruction, however, the values are not appearing with a separator on the front end and also, the 'Not' values are appearing - which is not what I want. See attached "Front End".

However, what I have done is left the 'not selected' fields blank and then inserted the shortcode, which has made the correct values appear on the front end (see attached). What Shortcode could I add to the existing shortcode below to display separators between values? (e.g., EU, MSA, Organic).

[types field='accredditations-test' state="checked" option="0"]PCAS[/types][types field='accredditations-test' state="checked" option="1"]EU[/types][types field='accredditations-test' state="checked" option="2"]MSA[/types][types field='accredditations-test' state="checked" option="3"]Organic[/types][types field='accredditations-test' state="checked" option="4"]Teys Grasslands Pasture-fed[/types]

Thanks

#924459

Also, the shortcodes were working fine before the update. Since the update the checkbox shortcodes are not working.

#947799

You can use the CSS :after pseudo-selector and :last-child pseudo-element like this:

<span class="cb-labels">
[types field='accredditations-test' state="checked" option="0"]<span class="cb-label">PCAS</span>[/types][types field='accredditations-test' state="checked" option="1"]<span class="cb-label">EU</span>[/types][types field='accredditations-test' state="checked" option="2"]<span class="cb-label">MSA</span>[/types][types field='accredditations-test' state="checked" option="3"]<span class="cb-label">Organic</span>[/types][types field='accredditations-test' state="checked" option="4"]<span class="cb-label">Teys Grasslands Pasture-fed</span>[/types]</span>

Then in the CSS panel:

.cb-label:after {
	content: ', ';
}
.cb-label:last-child:after {
	content: '';
}