[minor] validate web form and upload in customize form
This commit is contained in:
parent
930fc9a803
commit
b79dfe9970
4 changed files with 30 additions and 6 deletions
|
|
@ -4,6 +4,9 @@
|
|||
frappe.provide("frappe.customize_form");
|
||||
|
||||
frappe.ui.form.on("Customize Form", {
|
||||
setup: function(frm) {
|
||||
frm.get_docfield("fields").allow_bulk_edit = 1;
|
||||
},
|
||||
onload: function(frm) {
|
||||
frappe.customize_form.add_fields_help(frm);
|
||||
|
||||
|
|
|
|||
|
|
@ -195,10 +195,11 @@ class CustomizeForm(Document):
|
|||
|
||||
def update_custom_fields(self):
|
||||
for i, df in enumerate(self.get("fields")):
|
||||
if df.get("__islocal"):
|
||||
self.add_custom_field(df, i)
|
||||
else:
|
||||
self.update_in_custom_field(df, i)
|
||||
if df.get("is_custom_field"):
|
||||
if not frappe.db.exists('Custom Field', {'dt': self.doc_type, 'fieldname': df.fieldname}):
|
||||
self.add_custom_field(df, i)
|
||||
else:
|
||||
self.update_in_custom_field(df, i)
|
||||
|
||||
self.delete_custom_fields()
|
||||
|
||||
|
|
@ -209,8 +210,8 @@ class CustomizeForm(Document):
|
|||
|
||||
for property in docfield_properties:
|
||||
d.set(property, df.get(property))
|
||||
|
||||
if i!=0:
|
||||
|
||||
if i!=0:
|
||||
d.insert_after = self.fields[i-1].fieldname
|
||||
d.idx = i
|
||||
|
||||
|
|
@ -221,6 +222,7 @@ class CustomizeForm(Document):
|
|||
meta = frappe.get_meta(self.doc_type)
|
||||
meta_df = meta.get("fields", {"fieldname": df.fieldname})
|
||||
if not (meta_df and meta_df[0].get("is_custom_field")):
|
||||
# not a custom field
|
||||
return
|
||||
|
||||
custom_field = frappe.get_doc("Custom Field", meta_df[0].name)
|
||||
|
|
|
|||
|
|
@ -460,6 +460,11 @@ frappe.ui.form.Grid = Class.extend({
|
|||
if(df.fieldtype==="Date" && value) {
|
||||
value = frappe.datetime.user_to_str(value);
|
||||
}
|
||||
|
||||
if(df.fieldtype==="Int" || df.fieldtype==="Check") {
|
||||
value = cint(value);
|
||||
}
|
||||
|
||||
d[fieldnames[ci]] = value;
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,6 +36,20 @@ class WebForm(WebsiteGenerator):
|
|||
and self.is_standard and not frappe.conf.developer_mode):
|
||||
frappe.throw(_("You need to be in developer mode to edit a Standard Web Form"))
|
||||
|
||||
self.validate_fields()
|
||||
|
||||
def validate_fields(self):
|
||||
'''Validate all fields are present'''
|
||||
from frappe.model import no_value_fields
|
||||
missing = []
|
||||
meta = frappe.get_meta(self.doc_type)
|
||||
for df in self.web_form_fields:
|
||||
if df.fieldname and (df.fieldtype not in no_value_fields and not meta.has_field(df.fieldname)):
|
||||
missing.append(df.fieldname)
|
||||
|
||||
if missing:
|
||||
frappe.throw(_('Following fields are missing:') + '<br>' + '<br>'.join(missing))
|
||||
|
||||
def reset_field_parent(self):
|
||||
'''Convert link fields to select with names as options'''
|
||||
for df in self.web_form_fields:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue