diff --git a/frappe/templates/generators/web_form.html b/frappe/templates/generators/web_form.html index 8755de0d61..755576d328 100644 --- a/frappe/templates/generators/web_form.html +++ b/frappe/templates/generators/web_form.html @@ -145,7 +145,8 @@ {%- endif %}

+ {{ properties(field) }} + {%- if value(field, _doc) -%} data-value="{{ value(field, _doc) }}"{%- endif -%}>

{{ _("Max attachment size is {0}MB").format(max_attachment_size) }}

@@ -373,6 +374,7 @@ frappe.ready(function() { // clear attachment $(input).val(''); + $(input).attr('data-value', ''); }; frappe.file_reading = false; @@ -421,7 +423,7 @@ frappe.ready(function() { var input_wrapper = $(this).parent().addClass("hide") .parent().find(".attach-input-wrap").removeClass("hide"); - input_wrapper.find('input').val(''); + input_wrapper.find('input').val('').attr('data-value', ''); frappe.form_dirty = true; @@ -550,8 +552,12 @@ frappe.ready(function() { if($input.get(0).filedata) { var val = $input.get(0).filedata; } else { - var val = {'__no_attachment': 1} - no_attachment = true; + // original value + var val = $input.attr('data-value'); + if (!val) { + val = {'__no_attachment': 1} + no_attachment = true; + } } } else if(input_type==="checkbox") { var val = $input.prop("checked") ? 1 : 0;