popup-form.phtml 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. /**
  3. * @version 7.6
  4. */
  5. echo $this->script()->displayHeaderCode(); ?>
  6. <?php foreach ((array)$this->messages as $message) { ?>
  7. <div class="alert alert-dismissable <?php echo $message['class']; ?>">
  8. <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
  9. <?php if (is_array($message['msg'])) { ?>
  10. <?php foreach ((array)$message['msg'] as $msg) { ?>
  11. <div><?php echo $this->_($msg); ?></div>
  12. <?php } ?>
  13. <?php
  14. } else {
  15. ?>
  16. <?php echo $this->_($message['msg']); ?>
  17. <?php } ?>
  18. </div>
  19. <?php } ?>
  20. <form data-async method="<?php echo $this->form->getMethod(); ?>" action="<?php echo $this->form->getAction(); ?>"
  21. class="form-horizontal">
  22. <?php echo $this->form->hiddenElements; ?>
  23. <?php foreach ($this->form->getElements() as $element) { ?>
  24. <?php if (!$element->isHidden()) { ?>
  25. <?php echo $this->partial('partials/form-element.phtml', array('element' => $element)); ?>
  26. <?php } ?>
  27. <?php } ?>
  28. </form>
  29. <!-- included jquery because this is a bootbox popup -->
  30. <script src="<?php echo $this->baseUrl; ?>/js/jquery.min.js"></script>
  31. <script src="<?php echo $this->baseUrl; ?>/js/bootstrap.min.js"></script>
  32. <?php echo $this->script()->displayBodyCode(); ?>
  33. <script type="text/javascript">
  34. $(document).ready(function () {
  35. // submit modal forms in the modal box, and replace the current html with the response html
  36. $('form[data-async]').find('[type=submit]').on('click', function (e) {
  37. e.preventDefault();
  38. $(this).attr('disabled', true).val('Please wait..');
  39. var form = $(this).closest('form');
  40. var target = form.attr('data-target');
  41. $.ajax({
  42. type: form.attr('method'),
  43. url: form.attr('action'),
  44. data: form.serialize(),
  45. success: function (data) {
  46. $('.bootbox-body').html(data);
  47. }
  48. });
  49. });
  50. });
  51. </script>