Home › Forums › ACF PRO › Show icon if checkbox is checked › Reply To: Show icon if checkbox is checked
With return value, I’ve tried the 3 options:
1. Value
This works and display the label correctly ONLY if I have removed the VALUE ‘pet’ from pet: Pet Friendly in Choices.
2. Label
This works and display the label correctly ONLY if I have removed the VALUE ‘pet’ from pet: Pet Friendly in Choices.
If i leave the ‘pet’ in i.e. pet: Pet Friendly
I get Notice: Undefined index: Pet Friendly in
3. Array (both)
Error on every facility
Warning: Illegal offset type in
It appears I need to use the Array option so it can collect both the value and the label.
If that’s the case, I’ll need to redo the code to display all the Facilities…
which is currently:
<?php
$field = get_field_object('hh_facilities');
$value = $field['value'];
$choices = $field['choices'];
if( $value ): ?>
<ul>
<?php foreach( $value as $v ): ?>
<li>
<?php echo $choices[ $v ]; ?>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.