Tell us what you are trying to do? How can I show each single checkbox value and give them out as single element?
I have a multiple checkboxes field, and it is usable, that it's checked on more than one box. How can I do this?
I think I would like to use some custom code in php, but I don't know how to use the variables.
Is there any documentation that you are following?
Is there a similar example that we can see?
What is the link to your site?
Hello and thank you for contacting Toolset support.
I believe that you opened a chat and disconnected from it before I could reply to you, right? If that's the case, please accept my apologies, I was also working on another case and I did not reply quickly.
Regarding your request, I am sorry but I don't think I understand. Is this about a "Checkbox" field, or about a "Checkboxes" field? Please note that those are different Toolset Fields. Check this screenshot hidden link
I assume it is the "Checkboxes" field. In this case, can you elaborate more on what would you mean by "How can I show each single checkbox value" And what do you mean by "give them out as single element?"
Can you provide an example or some screenshots?
Dear Jamal
Yes, it is about the Checkboxes field. I try to explain what I like to achieve:
On a custom post type, more than one check of this checkboxes field are selected. I did set like this, that I get the "value" like
V, Vt, GF, DF etc out - but I not need them like this as I get them directly, I like to add some "css/html" around each value, like:
<div class="diettype">
<div class="mydiettype">V</div>
<div class="mydiettype">Vt</div>
<div class="mydiettype">GF</div>
<div class="mydiettype">DF</div>
</div>
This is what I like to see in html...
I found this: https://toolset.com/forums/topic/checkboxes-with-php/
But i am not sure if there is a better solution...
I would like to have a function in my custom code.
$checkboxes = types_field_meta_value('checkboxes');
foreach ($checkboxes as $value) {
if ( $value ) {
echo '[div class="checked"]' . $value . '[/div]';
} else {
echo '[div class="unchecked"]Not used[/div]' ;
}
}
Anything or elsewhere I can find it?
If you will have the checkboxes values wrapped in a static HTML code(vs dynamically changing the class), you can use the separator attribute of the types shortcode:
<div class="diettype">
<div class="mydiettype">
[types field="my-checkboxes" separator="</div><div class="mydiettype">"][/types]
</div>
</div>
Does it makes sense?
If you want to generate dynamic classes for each value, you will definitely need custom code. If that's the case, let me know and I'll find out a solution.
My issue is resolved now. Thank you!
I did it like this now:
<div class="mydiettypes">
<div class='res-circle'><div class='circle-txt'>[types field="eidosdiatrofis" separator="</div></div><div class='res-circle'><div class='circle-txt'>"][/types]</div></div>
</div>