Roych Posted January 6, 2019 Share Posted January 6, 2019 Hello, My first time trying to add form to a modal box. I got it loaded, but after submitting or if there is an error my modal box closes. Is there any way to leave it open until it is succesfully submitted and the success text would also show in the same modal box until I close the modal box myself. Im using the FormTemplateProcessor module for forms. Right now my code is: <button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#forma">Buy a Ticket</button> <div class="modal fade" id="forma" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> <h4 class="modal-title" id="myModalLabel">Buy a Ticket</h4> </div> <div class="modal-body"> <?php if ($page->koledar_obrazec) : ?> <?php echo $page->text_k_nakupu_kart ?> <br> <?php $form = $modules->get('FormTemplateProcessor');$form->template = $templates->get('Obrazec-karte-dogodki'); // required $form->requiredFields = array('obrazec_vstopnice_ime', 'obrazec_vstopnice_mail', 'obrazec_vstopnice_naslov', 'obrazec_vstopnice_telefon'); $form->email = 'info@povemodkrito.com'; // optional, sends form as email $form->parent = $page; // optional, saves form as page echo $form->render(); // draw form or process submitted form ?> <?php endif; ?></div> <div class="modal-footer"> <button type="button" class="btn btn-default inverted" data-dismiss="modal">Close</button> </div> </div> </div> </div> I tried to look on the forum, but not sure what to look for exactly as I have never done this before. Any help greatly appreciated. Thank you R Link to comment Share on other sites More sharing options...
strandoo Posted August 20, 2019 Share Posted August 20, 2019 Hi Roych. Did you ever solve this? I'm trying the same thing with pretty much the same results, so I'd be interested if you did. Link to comment Share on other sites More sharing options...
dragan Posted August 20, 2019 Share Posted August 20, 2019 @strandoo Do you have a live example? Most likely the modal is closed with JS. A quick look at Ryan's module tells me there's just the .module file without any JS. Probably the data-dismiss="modal" is triggered somewhere after submit... Link to comment Share on other sites More sharing options...
strandoo Posted August 20, 2019 Share Posted August 20, 2019 @dragan I’m using the SimpleContactForm module, not Ryan’s. It’s my “go to” contact form solution lately, but I’ve only just tried it in a modal today (actually, I’m trying it with the featherlight.js light box plugin for the pop up functionality). I’ve done it with a hand-rolled form with Ajax, so I’ll probably just do that again. It’s on a local machine. If I try to make it work, I’ll post it. Link to comment Share on other sites More sharing options...
Roych Posted August 20, 2019 Author Share Posted August 20, 2019 4 hours ago, strandoo said: Hi Roych. Did you ever solve this? I'm trying the same thing with pretty much the same results, so I'd be interested if you did. Hey, no I didn't, sry. I chose a different path that was still working ok. R Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now