Support

Account

Home Forums Add-ons Flexible Content Field Set subfield wrapper width based on radio value Reply To: Set subfield wrapper width based on radio value

  • Hi @harnessmedia

    Could you please let me know where you want it to happens? Backend or front-end?

    For the front-end, you can easily check the radio field value and apply the class accordingly. Here’s a simple example how you can do it:

    <?php
    
    $column = get_field('column_field');
    $css_width = 'width: 100%;'
    
    if( $column == '2' ){
        $css_width = 'width: 50%;'
    } elseif ( $column == '3' ){
        $css_width = 'width: 33%;'
    }
    
    ?>
    
    <div style="<?php echo $css_width ?>">this is the content</div>

    For the backend, you need to use JavaScript to check the selected value and add the width style. This page should give you more idea about it: https://www.advancedcustomfields.com/resources/adding-custom-javascript-fields/.

    I hope this helps 🙂