[web-form] validate in server before saving
This commit is contained in:
parent
d2db71f8c4
commit
538d8e3d2d
3 changed files with 14 additions and 15 deletions
|
|
@ -436,15 +436,13 @@ frappe.ready(function() {
|
|||
// change section
|
||||
$('.btn-change-section, .slide-progress .icon-fixed-width').on('click', function() {
|
||||
var idx = $(this).attr('data-idx');
|
||||
show_slide(idx);
|
||||
if(frappe.form_dirty && !frappe.is_read_only) {
|
||||
try {
|
||||
save();
|
||||
} catch(e) {
|
||||
// pass
|
||||
if(!frappe.form_dirty || frappe.is_read_only) {
|
||||
show_slide(idx);
|
||||
} else {
|
||||
if(save()!==false) {
|
||||
show_slide(idx);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
show_slide = function(idx) {
|
||||
|
|
@ -599,16 +597,14 @@ frappe.ready(function() {
|
|||
if(frappe.file_reading) {
|
||||
window.saving = false;
|
||||
frappe.msgprint(__("Uploading files please wait for a few seconds."));
|
||||
throw 'reading files';
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
var data = get_data();
|
||||
if(frappe.allow_incomplete && frappe.mandatory_missing.length) {
|
||||
if((!frappe.allow_incomplete || for_payment) && frappe.mandatory_missing.length) {
|
||||
window.saving = false;
|
||||
show_mandatory_missing();
|
||||
throw 'mandatory missing';
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
frappe.call({
|
||||
|
|
@ -646,6 +642,7 @@ frappe.ready(function() {
|
|||
window.saving = false;
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
function show_mandatory_missing() {
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
<div class="{% if show_sidebar %}page-content with-sidebar col-sm-9{% else %} page-content col-sm-12 {% endif %}">
|
||||
<div class="page-content-wrapper">
|
||||
<div class="row page-head">
|
||||
<div class="col-sm-8 col-xs-6">
|
||||
<div class='col-sm-12'>
|
||||
{% if not no_breadcrumbs and parents %}
|
||||
<div class="page-breadcrumbs">
|
||||
{% block breadcrumbs %}
|
||||
|
|
@ -21,6 +21,8 @@
|
|||
{% endblock %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="col-sm-8 col-xs-6">
|
||||
{% block header %}{% endblock %}
|
||||
</div>
|
||||
<div class="col-sm-4 col-xs-6">
|
||||
|
|
|
|||
|
|
@ -306,12 +306,12 @@ def get_context(context):
|
|||
'''Validate mandatory web form fields'''
|
||||
missing = []
|
||||
for f in self.web_form_fields:
|
||||
if f.reqd and doc.get(f.fieldname) in (None, []):
|
||||
if f.reqd and doc.get(f.fieldname) in (None, [], ''):
|
||||
missing.append(f)
|
||||
|
||||
if missing:
|
||||
frappe.throw(_('Mandatory Information missing:') + '<br><br>'
|
||||
+ '<br>'.join([d.label for d in missing]))
|
||||
+ '<br>'.join(['{0} ({1})'.format(d.label, d.fieldtype) for d in missing]))
|
||||
|
||||
|
||||
@frappe.whitelist(allow_guest=True)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue