From 2abf5f9a06934a58ee23dfbe22495c7cc5ca2744 Mon Sep 17 00:00:00 2001 From: Harsh Tandiya Date: Thu, 15 Jan 2026 00:42:28 +0530 Subject: [PATCH 1/2] feat: add 'hidden' field to form field configuration --- forms_pro/forms_pro/doctype/form_field/form_field.json | 9 ++++++++- forms_pro/forms_pro/doctype/form_field/form_field.py | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/forms_pro/forms_pro/doctype/form_field/form_field.json b/forms_pro/forms_pro/doctype/form_field/form_field.json index 5f74562..11d7e49 100644 --- a/forms_pro/forms_pro/doctype/form_field/form_field.json +++ b/forms_pro/forms_pro/doctype/form_field/form_field.json @@ -7,6 +7,7 @@ "engine": "InnoDB", "field_order": [ "reqd", + "hidden", "label", "fieldtype", "fieldname", @@ -68,13 +69,19 @@ "fieldname": "conditional_logic", "fieldtype": "Code", "label": "Conditional Logic" + }, + { + "default": "0", + "fieldname": "hidden", + "fieldtype": "Check", + "label": "Hidden" } ], "grid_page_length": 50, "index_web_pages_for_search": 1, "istable": 1, "links": [], - "modified": "2026-01-14 21:40:40.060805", + "modified": "2026-01-15 00:41:11.397823", "modified_by": "Administrator", "module": "Forms Pro", "name": "Form Field", diff --git a/forms_pro/forms_pro/doctype/form_field/form_field.py b/forms_pro/forms_pro/doctype/form_field/form_field.py index 3c41811..d196130 100644 --- a/forms_pro/forms_pro/doctype/form_field/form_field.py +++ b/forms_pro/forms_pro/doctype/form_field/form_field.py @@ -36,6 +36,7 @@ class FormField(Document): "Checkbox", "Rating", ] + hidden: DF.Check label: DF.Data options: DF.SmallText | None parent: DF.Data From fb2d3004fea3001dd4f4f9ed69fbf8f48884d78b Mon Sep 17 00:00:00 2001 From: Harsh Tandiya Date: Thu, 15 Jan 2026 00:48:52 +0530 Subject: [PATCH 2/2] feat: implement 'hidden' property for form fields and update visibility logic --- .../field-editor/FieldPropertiesForm.vue | 9 +++++ frontend/src/types/formfield.ts | 1 + frontend/src/utils/conditionals.ts | 34 ++++++++++++------- 3 files changed, 32 insertions(+), 12 deletions(-) diff --git a/frontend/src/components/builder/field-editor/FieldPropertiesForm.vue b/frontend/src/components/builder/field-editor/FieldPropertiesForm.vue index 368e0c9..4183359 100644 --- a/frontend/src/components/builder/field-editor/FieldPropertiesForm.vue +++ b/frontend/src/components/builder/field-editor/FieldPropertiesForm.vue @@ -56,6 +56,15 @@ const fieldProperties = computed(() => { description: "If enabled, the field becomes required and cannot be left blank.", }, }, + { + fieldname: "hidden", + component: FormControl, + props: { + type: "checkbox", + label: "Hidden", + description: "If enabled, the field is hidden from the form.", + }, + }, { fieldname: "description", component: FormControl, diff --git a/frontend/src/types/formfield.ts b/frontend/src/types/formfield.ts index 513415b..47944de 100644 --- a/frontend/src/types/formfield.ts +++ b/frontend/src/types/formfield.ts @@ -23,6 +23,7 @@ export type FormField = { fieldtype: FormFieldTypes; description?: string; reqd?: boolean; + hidden?: boolean; options?: string; default?: string; idx?: number; diff --git a/frontend/src/utils/conditionals.ts b/frontend/src/utils/conditionals.ts index f48bc9e..8fae4f0 100644 --- a/frontend/src/utils/conditionals.ts +++ b/frontend/src/utils/conditionals.ts @@ -215,18 +215,27 @@ function evaluateConditions( } /** - * Determine if a field should be visible based on conditional logic rules - * defined on other fields that target this field. Visibility is driven by - * rules on other fields, not a property on the field itself. A field is visible if: - * - No conditional logic rules target it, OR - * - At least one "Show Field" action evaluates to true, OR - * - No "Hide Field" actions evaluate to true + * Determine if a field should be visible based on: + * 1. The field's `hidden` property (base state) + * 2. Conditional logic rules defined on other fields that target this field + * + * Visibility logic: + * - If field.hidden === true, field starts as hidden + * - If field.hidden === false or undefined, field starts as visible + * - Conditional logic can override the base state: + * - "Show Field" action can make a hidden field visible + * - "Hide Field" action can make a visible field hidden + * - If no conditional logic applies, the base hidden state is used */ export function shouldFieldBeVisible( field: FormField, formValues: Record, allFields: FormField[] ): boolean { + // Start with the field's base hidden state + // If hidden is true, field is hidden by default; if false/undefined, it's visible + const baseIsVisible = !field.hidden; + // Find all conditional logic rules that target this field const targetingRules: ConditionalLogic[] = []; @@ -239,9 +248,9 @@ export function shouldFieldBeVisible( } }); - // If no rules target this field, it's visible + // If no rules target this field, use the base hidden state if (targetingRules.length === 0) { - return true; + return baseIsVisible; } // Check each rule @@ -260,18 +269,19 @@ export function shouldFieldBeVisible( } } - // If any "Show Field" rule is met, field is visible + // Conditional logic overrides base state: + // - "Show Field" action can override hidden state (make it visible) if (hasShowRule) { return true; } - // If any "Hide Field" rule is met, field is hidden + // - "Hide Field" action can override visible state (make it hidden) if (hasHideRule) { return false; } - // Default: field is visible if no rules are met - return true; + // If no conditional rules are met, use the base hidden state + return baseIsVisible; } /**