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
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 🙂
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.