You might get the wrong impression by the title of this thread. Forms in Bootstrap's Modal plugin aren't broken so there is nothing to fix, this is just a little code that improves the forms.
For example, you may have a Modal dialog with a form inside of it and the user may edit some of the information in the form and then close the dialog without submitting the form, this means that when the user reopens the dialog, the information won't be in it's truest state and this wasn't good for the project I'm working on at the minute so I spent 2 minutes writing this code to reset all of the forms in each Modal dialog.
This code will mean that when the user reopens the dialog, the information in the form will be in its truest state.
I hope this helped.
- Mark
For example, you may have a Modal dialog with a form inside of it and the user may edit some of the information in the form and then close the dialog without submitting the form, this means that when the user reopens the dialog, the information won't be in it's truest state and this wasn't good for the project I'm working on at the minute so I spent 2 minutes writing this code to reset all of the forms in each Modal dialog.
PHP:
$("div.modal[role='dialog']").each(function(i,a){
$(a).on('hidden', function(){
var allforms = $(this).find('form');
if (allforms.length > 0) {
$(allforms).each(function(k,p){
$(p)[0].reset();
});
}
});
});
This code will mean that when the user reopens the dialog, the information in the form will be in its truest state.
I hope this helped.
- Mark