<script type="text/javascript">
$('#form_reset_btn').on('click', function () {
let $form = $(this).closest('.card').find('form');
// Reset the whole form
$form[0].reset();
// Clear inputs manually, except those with .ignore_reset
$form.find('input:not(.ignore_reset), textarea:not(.ignore_reset)').each(function () {
$(this).val('');
});
// Reset selects, excluding those with .ignore_reset
$form.find('select:not(.ignore_reset)').each(function () {
$(this).val('').trigger('change'); // Also works with select2
});
$form.find('select.ignore_reset').each(function () {
if ($(this).attr('data-default_value')) {
var value = $(this).attr('data-default_value');
$(this).val(value).trigger('change');
}
});
});
</script>