How to add or remove fields in frappe.ui.Dialog based on conditions?


Currently I am maintaining three different versions frappe.ui.Dialog to show some fields and to hide other or to make some fields mandatory depending on status. Like for example if the DocStatus is 0 then show certain fields and make them mandatory but if DocStatus is 1 then show the fields as Read only.

Because of this my client Script is growing very long and becoming tough to manage it.

Instead can I add some kind of condition at field definition level to remove certain fields?


Yogi Yang