![]() |
Submitting Form With Bootstrap Modal Question - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: Submitting Form With Bootstrap Modal Question (/showthread.php?tid=63138) |
Submitting Form With Bootstrap Modal Question - wolfgang1983 - 09-29-2015 When I submit my form on my bootstrap modal, if any errors found I would like to be able to add class and stop it from closing if any errors found What is the best solution Script PHP Code: <script type="text/javascript"> Controller Delete Function PHP Code: public function delete() { View PHP Code: <?php echo $header;?> RE: Submitting Form With Bootstrap Modal Question - mwhitney - 09-30-2015 Unless you have some JavaScript to override and prevent the default behavior of the submit button, submitting the form results in a new page being loaded by the browser, even if it happens to be the same page. You can check for validation errors and show the modal again when the page loads. If you are preventing the default behavior and submitting the form via AJAX, then you would just have to send back some indication that validation failed and check for that in the JavaScript code which is run to process the response. If the response indicates there were no validation errors, you close the modal, otherwise, you display the errors. RE: Submitting Form With Bootstrap Modal Question - wolfgang1983 - 09-30-2015 (09-30-2015, 08:04 AM)mwhitney Wrote: Unless you have some JavaScript to override and prevent the default behavior of the submit button, submitting the form results in a new page being loaded by the browser, even if it happens to be the same page. You can check for validation errors and show the modal again when the page loads. Do you have any examples? Or links RE: Submitting Form With Bootstrap Modal Question - mwhitney - 10-01-2015 Opening a bootstrap modal on page load: http://stackoverflow.com/questions/10233550/launch-bootstrap-modal-on-page-load jQuery AJAX forum submission with Bootstrap modal: https://gist.github.com/havvg/3226804 CodeIgniter AJAX modal form validation and submit: http://stackoverflow.com/questions/21465285/ajax-modal-form-validation-and-submit http://lmgtfy.com/?q=bootstrap+modal+form+ajax+codeigniter |