Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Retain filename when a file isn't changed

  • Loading branch information...
commit 3063357cbdb09d62f2c9ac2d3c2d3e41691bde0f 1 parent a6afecd
@ejs ejs authored
View
5 formish/templates/mako/formish/widgets/FileUpload/widget.html
@@ -4,10 +4,12 @@
value_name = ''
value_default = ''
mimetype = ''
+ filename = ''
else:
value_name = field.value['name'][0]
value_default = field.value['default'][0]
mimetype = field.value['mimetype'][0]
+ filename = field.value['filename'][0]
if mimetype is None:
mimetype = ''
%>
@@ -39,10 +41,11 @@
% if value_name and field.widget.show_remove_checkbox:
<label for="${field.cssname}-remove">
<input id="${field.cssname}-remove" type="checkbox" name="${field.name}.remove" value="true" class="widget-fileupload-remove" />
- Remove ${field.value.get('filename', ['this file'])[0]}
+ Remove ${filename}
</label>
% endif
<input id="${field.cssname}-id" type="hidden" name="${field.name}.name" value="${value_name}" />
<input id="${field.cssname}-mimetype" type="hidden" name="${field.name}.mimetype" value="${mimetype}" />
<input id="${field.cssname}-default" type="hidden" name="${field.name}.default" value="${value_default}" />
+<input id="${field.cssname}-filename" type="hidden" name="${field.name}.filename" value="${filename}" />
<input id="${field.cssname}" type="file" name="${field.name}.file" />
View
2  formish/widgets.py
@@ -714,7 +714,7 @@ def from_request_data(self, field, request_data):
if request_data['name'] == ['']:
return None
elif request_data['name'] == request_data['default']:
- return SchemaFile(None, None, None, {'old_name':list(i for i in request_data['name'])})
+ return SchemaFile(None, request_data.get('filename', [None])[0], None, {'old_name':list(i for i in request_data['name'])})
else:
key = util.decode_file_resource_path(request_data['name'][0])[1]
try:
Please sign in to comment.
Something went wrong with that request. Please try again.