From 5c110bd48f31bd2e9f419590688c4f20c16c7c8c Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Wed, 28 Sep 2016 18:18:54 +0530 Subject: [PATCH] [fix] date parsing and formatting in web form --- frappe/templates/generators/web_form.html | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/frappe/templates/generators/web_form.html b/frappe/templates/generators/web_form.html index eafa76424e..6c8ca1f6de 100644 --- a/frappe/templates/generators/web_form.html +++ b/frappe/templates/generators/web_form.html @@ -21,7 +21,7 @@ {% elif is_list %}
- {{ _("New {0}").format(_(title)) }} + {{ _("New") }}
{% endif %} @@ -211,7 +211,8 @@ data-fieldname='{{ field.fieldname }}'>{{ _("Add Row") }}

{% endmacro %} -{% if layout|len > 1 %} + +{% if not frappe.form_dict.new and layout|len > 1 %}
{% for page in layout %} {{ _("Previous") }} {% endif %} - {% if loop.index == layout|len %} + {% if loop.index == layout|len or frappe.form_dict.new %} {% elif layout|len > 1 %} @@ -516,8 +517,12 @@ frappe.ready(function() { } else if(input_type==="checkbox") { var val = $input.prop("checked") ? 1 : 0; } else if($input.attr("data-fieldtype")==="Date") { - var val = $.datepicker.formatDate("yy-mm-dd", - $input.datepicker('getDate')); + // convert from user format to YYYY-MM-DD + if($input.val()) { + var val = moment($input.val(), moment.defaultFormat).format('YYYY-MM-DD'); + } else { + var val = null; + } } else { var val = $input.val(); } @@ -634,12 +639,11 @@ frappe.ready(function() { dateFormat: frappe.datepicker_format, }); - // convert dates to user format + // convert dates from YYYY-MM-DD to user format $dates.each(function() { var val = $(this).val(); if(val) { - $(this).val($.datepicker.formatDate(frappe.datepicker_format, - $.datepicker.parseDate("yy-mm-dd", val))); + $(this).val(moment(val, 'YYYY-MM-DD').format()); } }); }