Permalink
Browse files

Retain filename when a file isn't changed

  • Loading branch information...
1 parent a6afecd commit 3063357cbdb09d62f2c9ac2d3c2d3e41691bde0f @ejs ejs committed Feb 1, 2012
Showing with 5 additions and 2 deletions.
  1. +4 −1 formish/templates/mako/formish/widgets/FileUpload/widget.html
  2. +1 −1 formish/widgets.py
@@ -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
@@ -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:

0 comments on commit 3063357

Please sign in to comment.