Home › Forums › General Issues › How to create dynamic select in ACF and pass to CF7? › Reply To: How to create dynamic select in ACF and pass to CF7?
I found a solution! I hope it will be useful for someone else in future:
function add_date_to_cf7() {
$output = "<select name='date_corso' id='date_corso' onchange='document.getElementById(\"date_corso\").value=this.value;'><option></option>";
if( have_rows('gruppo_date') ) {
while( have_rows('gruppo_date') ) {
the_row();
$output .= '<option value="'.get_sub_field('intervallo_date_corso').'">' .get_sub_field('intervallo_date_corso'). '</option>';
}
}
$output .= "</select>";
return $output;
}
wpcf7_add_shortcode('date_corso', 'add_date_to_cf7', true);
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.