Home › Forums › Backend Issues (wp-admin) › Checkboxes with an 'Other' text field › Reply To: Checkboxes with an 'Other' text field
Thanks again for that clue @reardestani. I’ve spent some time today trying to copy from/reconcile code from radio.php into checkbox.php. It’s almost working but not quite. I think I have the code in the create_field() method working ok but it all seems to fall apart within the update_value() method.
function update_value( $value, $post_id, $field )
{
var_dump($value);
... <snip> ...
}
Produces (with the ‘other’ and another box checked)
array(2) {
[0]=>
string(8) "firstVAL"
[1]=>
string(5) "other"
}
Then, I loop through it
foreach($value as $key => $v)
{
if ( !in_array($v, $field['choices']) )
{
echo "key: " . $key . " / v: " . $v . "\n\n";
array_push($field['choices'], $v);
}
}
and that of course produces:
key: 0 / v: firstVAL
key: 1 / v: other
Not the value of the textinput but the value of the checkbox.
Can someone set me straight here? How can I find the value of that text input I’ve created within the create_field() function?
This is with the Save ‘other’ values to the field’s choices set to on FWIW. In the end, I won’t actually want that (awesome) functionality – there will be many different editors of this ‘form’ and they don’t all need to see the values saved by others. I tried turning it off but when I reloaded my my edit (custom) post, the value wasn’t saved. For now anyway, I’m going down this path.
Once I sort it out, I’ll clean up my mayhem and submit it as a pull request in case it’s useful to anyone else.
Cheers,
Will
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.