I am trying to pull dynamic form id to create a dropdown for the end-user. This I have done here.
Now, I'd like to pass that id so that a different form shows up based on selection as shown below:
<form class="ui form">
<select name="select" class="ui fluid search selection dropdown">
<?php $myforms = RGFormsModel::get_forms(); foreach ($myforms as $form) { ?>
<option name="select" value="<?php echo $form->id ?>"> <?php echo $form->title ?> </option>
<?php } ?>
</select>
</form>
<?php echo gravity_form($form, true, true, false, '', true, 1); ?>
Here's what I might do to make a shortcode for gravity forms that pulls the ID from the URL parameter.
function return_gform_embed(){
$form_id = $_GET["form_id"];
return do_shortcode('[gravityform id="'.$form_id.'" title="false" description="false"]');
}
add_shortcode('form-url', 'return_gform_embed');
You'd add the shortcode [form-url]
to the page where you'd like the form to display.
So now the URL with ?form_id=6
would load the gravity form with id 6. I didn't test the whole javascript aspect but assuming you can change the URL and force a reload things should work out ok.