$atts['form_id']
contains the form_id
that was passed with the Shortcode. You are searching for this form_id
among the data that is held in the forms
field.
$forms
is an array, and each item in the array is another array with your two keys: form_id
and form_markup
.
So, for each item in $forms
, you want to check if that form_id
matches the form_id
requested in the Shortcode. if there is a match, return
the form_markup
from that item.
If no matches were found, return
an error message.
$forms = get_field( 'forms', 'option' );
foreach ( $forms as $form ) {
if( $atts['form_id'] == $form['form_id'] ){
return $form['form_markup'];
}
}
return 'form id ' . $atts['form_id'] . ' not found';