Skip to content

Commit

Permalink
fix(layout): handle fieldobj being null
Browse files Browse the repository at this point in the history
`make_control` doesn't return anything when the control name is invalid
Handle in `make_field` and `init_field`

Signed-off-by: Akhil Narang <me@akhilnarang.dev>
(cherry picked from commit 883196d)
  • Loading branch information
akhilnarang authored and mergify[bot] committed Apr 9, 2024
1 parent 9e6b5af commit 4c11499
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion frappe/public/js/frappe/form/layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,10 @@ frappe.ui.form.Layout = class Layout {

const parent = this.column.wrapper.get(0);
const fieldobj = this.init_field(df, parent, render);

// An invalid control name will return in a null fieldobj
if (!fieldobj) return;

this.fields_list.push(fieldobj);
this.fields_dict[df.fieldname] = fieldobj;

Expand All @@ -230,7 +234,11 @@ frappe.ui.form.Layout = class Layout {
layout: this,
});

fieldobj.layout = this;
// make_control can return null for invalid control names
if (fieldobj) {
fieldobj.layout = this;
}

return fieldobj;
}

Expand Down

0 comments on commit 4c11499

Please sign in to comment.