Support

Account

Forum Replies Created

  • I solved it. Thanks for your replays. I used a radio button field eventually (instead of the checkbox). here is the code:

    
        <div class="single-filter-type">
            <?php  $field = get_field_object('weather'); ?>
            <h3><?php echo $field['label'] ?></h3>
        <?php 
            $checked = ' checked="checked"';
            $weather_values = get_field('weather');                   
            if( $weather_values ):  
                    foreach( $field['choices'] as $k => $v ){ 
                        if(get_field('weather') == $v) { $checked = "checked";}else {$checked = '';} ?>     <label class="filter-checkbox-item" for="<?php  echo $v;  ?>">
                                <input type="radio" name="weather" value="<?php echo $v;  ?>" <?php echo $checked ?> >
                                <?php echo $v;  ?>
                            </label>
                <?php }   
    
           endif; 
       ?> 
        </div>
    
  • Ok, I’m trying to have a list of radio inputs in a form on the front, when pulling the values from an acf field (that’s my checkbox field, but it doesn’t have to be a checkbox), and in addition to have the ability to set one of the choices as default checked.

    I tried to achieve it with a checkbox field, and tried with a radio field as well. In both options I’m facing an issue with setting one of the choices as default checked (I don’t have problems with pulling the values).

    Thanks, hopefully it makes sense

  • Sorry, will clarify. ‘weather’ is a checkbox field, yes. I have a custom form on the fly that I’m using for ajax filtering with the POST method. I have multiple lists. same as ‘weather’, that I’m using as radio buttons in the form, as I want only one value to be chosen in each list.
    Of course, ‘weather’ doesn’t have to be a checkbox field, I’m just trying to find a way it would be easy to a non coder to add the values. so my issue with the way it works now is the option to choose the default value from the dashboard..

    Thanks for your reply

  • Thank you, it works great for me.

Viewing 4 posts - 1 through 4 (of 4 total)