Home › Forums › Add-ons › Repeater Field › if (checkbox) = "Text" than html-Code › Reply To: if (checkbox) = "Text" than html-Code
Since I’ve now spent too much time trying to do the same thing, and finding this post with no update, I wanted to post a solution for others (or myself when I search again)
Even though “value” is selected on the checkbox, the item is still stored as an array. As such, you do just a normal “get_field” as you’d be getting an array that returns “1”.
We need the info contained in the array.
$variable = get_field(‘acffield’);
$var_value = $variable[‘value’];
Now we can see the values;
if ($var_value == “first”) {
echo “do this”;
}
elseif ($var_value ==”second”) {
echo “do that”;
}
Hopefully that gets someone else on the right track.
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.