Skip to content

Commit a3be637

Browse files
committed
Fix clear input on form reset, fix #110
1 parent e85b6a2 commit a3be637

File tree

10 files changed

+14
-0
lines changed

10 files changed

+14
-0
lines changed

dev/myapp/templates/myapp/bootstrap3/custom-form.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
{% bootstrap_form form %}
2323
{% buttons %}
2424
<button type="submit" class="btn btn-primary">{{ submit_text }}</button>
25+
<button type="reset" class="btn btn-warning">Reset</button>
2526
{% endbuttons %}
2627
</form>
2728
</div>

dev/myapp/templates/myapp/bootstrap3/custom-formset.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
{% endfor %}
2727
{% buttons %}
2828
<button type="submit" class="btn btn-primary">{{ submit_text }}</button>
29+
<button type="reset" class="btn btn-warning">Reset</button>
2930
{% endbuttons %}
3031
</form>
3132
</div>

dev/myapp/templates/myapp/bootstrap3/modal-form.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ <h3>{{ title_text }}</h3>
88
{% bootstrap_form form %}
99
{% buttons %}
1010
<button type="submit" class="btn btn-primary">{{ submit_text }}</button>
11+
<button type="reset" class="btn btn-warning">Reset</button>
1112
{% endbuttons %}
1213
</form>
1314
</div>

dev/myapp/templates/myapp/bootstrap4/custom-form.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ <h2 class="pb-2 mt-4 mb-2 border-bottom">Custom Form with Bootstrap 4</h2>
1818
{% bootstrap_form form %}
1919
{% buttons %}
2020
<button type="submit" class="btn btn-primary">{{ submit_text }}</button>
21+
<button type="reset" class="btn btn-warning">Reset</button>
2122
{% endbuttons %}
2223
</form>
2324
</div>

dev/myapp/templates/myapp/bootstrap4/custom-formset.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ <h2 class="pb-2 mt-4 mb-2 border-bottom">Custom Form with Bootstrap 4</h2>
2727
{% endfor %}
2828
{% buttons %}
2929
<button type="submit" class="btn btn-primary">{{ submit_text }}</button>
30+
<button type="reset" class="btn btn-warning">Reset</button>
3031
{% endbuttons %}
3132
</form>
3233
</div>

dev/myapp/templates/myapp/bootstrap4/modal-form.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ <h2 class="pb-2 mt-4 mb-2 border-bottom">Custom Form with Bootstrap 4</h2>
88
{% bootstrap_form form %}
99
{% buttons %}
1010
<button type="submit" class="btn btn-primary">{{ submit_text }}</button>
11+
<button type="reset" class="btn btn-warning">Reset</button>
1112
{% endbuttons %}
1213
</form>
1314
</div>

dev/myapp/templates/myapp/bootstrap5/custom-form.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ <h2 class="pb-2 mt-4 mb-2 border-bottom">Custom Form with Bootstrap 5</h2>
1717
{% csrf_token %}
1818
{% bootstrap_form form %}
1919
<button type="submit" class="btn btn-primary">{{ submit_text }}</button>
20+
<button type="reset" class="btn btn-warning">Reset</button>
2021
</form>
2122
</div>
2223
</div>

dev/myapp/templates/myapp/bootstrap5/custom-formset.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ <h2 class="pb-2 mt-4 mb-2 border-bottom">Custom Form with Bootstrap 5</h2>
2727
{% endfor %}
2828
<div class="mt-2">
2929
<button type="submit" class="btn btn-primary">{{ submit_text }}</button>
30+
<button type="reset" class="btn btn-warning">Reset</button>
3031
</div>
3132
</form>
3233
</div>

dev/myapp/templates/myapp/bootstrap5/modal-form.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ <h2 class="pb-2 mt-4 mb-2 border-bottom">{{ title_text }}</h2>
88
{% bootstrap_form form %}
99
{% bootstrap_alert "Demo site is static HTML clone of django, submitting won't work" alert_type='warning' %}
1010
<button type="submit" class="btn btn-primary">{{ submit_text }}</button>
11+
<button type="reset" class="btn btn-warning">Reset</button>
1112
</form>
1213
</div>
1314
</div>

src/bootstrap_datepicker_plus/static/bootstrap_datepicker_plus/js/datepicker-widget.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,11 @@
9292
const widgetInstance = createWidgetInstance(inputWrapper, hiddenInputElement, config);
9393
widgetInstances.set(hiddenInputElement, widgetInstance);
9494

95+
const form = hiddenInputElement.closest("form");
96+
form?.addEventListener("reset", () => {
97+
setTimeout(() => inputElement.dispatchEvent(new Event("change")));
98+
})
99+
95100
if (config.range_from) {
96101
const widgetRangeFromInstance = getRangeFromInputElement(hiddenInputElement, config);
97102
if (widgetRangeFromInstance) {

0 commit comments

Comments
 (0)