I have a repeater field using the Table layout in a front-end form, but this does not display well on mobile devices. The Block layout would look good on mobile, but I would like to keep the Table layout in desktop. Is there a way, either in a shortcode or php function, for me to dynamically change the layout of the form? If not, could this feature be made available soon?
Your title-game is not exactly on point…
Hi @nmgacf
For something like that, you would need to detect the user’s device first. Please take a look at this thread to learn more about it: http://stackoverflow.com/questions/4117555/simplest-way-to-detect-a-mobile-device.
After that, you can change the repeater layout by using the acf/prepare_field hook like this:
function change_repeater_layout( $field ) {
$field['layout'] = 'block';
return $field;
}
add_filter('acf/prepare_field/name=repeater', 'change_repeater_layout');
I hope this helps 🙂