Skip to content

Commit 80bee98

Browse files
authored
Update form.handlebars
Proposed changes for improved handling of form encoding types
1 parent 20eec0a commit 80bee98

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

sqlpage/templates/form.handlebars

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
{{#if id}}id="{{id}}"{{/if}}
33
class="my-3 {{class}}"
44
method="{{default method "post"}}"
5-
{{#if enctype}}enctype="{{enctype}}"{{/if}}
5+
enctype="{{default enctype "multipart/form-data"}}"
6+
<!-- For efficiency, change the form encoding type on the default submit button if there is no file input -->
7+
{{default_submit_formenctype = default enctype "application/x-www-form-urlencoded"}}
68
{{#if action}}action="{{action}}"
79
{{else}}
810
{{#if id}}action="#{{id}}"{{/if}}
@@ -120,8 +122,8 @@
120122
{{/if}}
121123
{{/if}}
122124
{{#if eq type "file"}}
123-
<!-- Change the form encoding type if this is a file input -->
124-
{{#delay}}formenctype="multipart/form-data"{{/delay}}
125+
<!-- Change the form encoding type on the default submit button if there is a file input and user has not set form enctype -->
126+
{{default_submit_formenctype = default enctype "multipart/form-data"}}
125127
{{/if}}
126128
{{/each_row}}
127129
</div>
@@ -131,7 +133,9 @@
131133
{{#if validate_shape}} btn-{{validate_shape}} {{/if}}
132134
{{#if validate_outline}} btn-outline-{{validate_outline}} {{/if}}
133135
{{#if validate_size}} btn-{{validate_size}} {{/if}}"
134-
{{flush_delayed}}
136+
{{#if and (has_file not (enctyp}}
137+
formenctype={{default_submit_formenctype}}
138+
{{/fi}}
135139
type="submit"
136140
{{#if validate}}value="{{validate}}"{{/if}}>
137141
{{/if}}

0 commit comments

Comments
 (0)