Support

Account

Home Forums General Issues Update checbox

Helping

Update checbox

  • Is there a way to set a checkbox (or radiobutton) checked from a list, based on its value? Maybe using for example the update_field function?

    I have a survey where I create a new post, and I want to update the custom field with the users selections checked. In other words, not changing the values/options of a checkbox array – but setting which ones are selected ๐Ÿ™‚

  • Hi @sd

    It is possible to modify a field immediately after it is loaded from the database using the acf/load_field hook. Something in the lines of this:

    <?php
    
    function my_acf_load_field( $field )
    {
        $field['choices'] = array(
            'custom' => 'My Custom Choice'
        );
    
        return $field;
    }
    
    // acf/load_field - filter for every field
    add_filter('acf/load_field', 'my_acf_load_field');
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.