Skip to content

feat: add Page Break field type for multistep forms#150

Open
harshtandiya wants to merge 4 commits into
developfrom
feat/page-break-multistep
Open

feat: add Page Break field type for multistep forms#150
harshtandiya wants to merge 4 commits into
developfrom
feat/page-break-multistep

Conversation

@harshtandiya
Copy link
Copy Markdown
Collaborator

@harshtandiya harshtandiya commented Jun 4, 2026

Summary

  • Adds Page Break as a new display-only field type (like Heading 1/2/3)
  • Maps to Frappe HTML fieldtype, generates <hr> on linked DocType
  • Skipped in submission validation, excluded from export — zero impact on existing forms
  • Backend-only groundwork for multistep form UI (frontend phase to follow)

Changes

  • form_field.json — added Page Break to fieldtype options
  • form_field.py — mapping, display-only set, get_options() returns <hr>
  • test_submission_validation.py — 6 unit tests
  • test_page_break.py — 2 integration tests
  • form_field.types.ts — auto-generated enum member

Test plan

  • 36/36 tests pass (bench run-tests --app forms_pro)
  • Pre-commit clean (ruff, prettier, oxlint)
  • Verify Page Break appears in form builder field palette
  • Verify form with Page Break saves via UI
  • Verify submissions still work with Page Break fields present

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added a Page Break field type for forms — displayed as a non-input divider between fields and no longer renders as a heading.
  • Bug Fixes

    • Page Breaks no longer suppress validation of adjacent required fields.
  • Tests

    • Added unit and integration tests covering Page Break display, validation behavior, and sync to linked forms.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 4, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

Adds a Page Break form field type: frontend/back-end type declarations, backend mapping to Frappe "Tab Break" and display-only behavior, adjusted get_options() logic (no heading HTML for Page Break), plus unit and integration tests for validation, persistence, and DocType sync.

Changes

Page Break Field Type Support

Layer / File(s) Summary
Field type contracts
frontend/src/types/FormsPro/form_field.types.ts, forms_pro/forms_pro/doctype/form_field/form_field.json
Frontend Fieldtype enum and backend Form Field doctype options add Page Break as a selectable field type.
Backend mapping and options behavior
forms_pro/forms_pro/doctype/form_field/form_field.py
FORM_TO_FRAPPE_FIELDTYPE maps Page Break to Frappe's Tab Break; _DISPLAY_ONLY_FIELDTYPES includes Page Break; get_options() now only returns heading HTML for Heading 1–3 (Page Break no longer returns heading markup).
Submission validation unit tests
forms_pro/api/submission/test_submission_validation.py (lines 246–283)
Unit tests verify Page Break fields are skipped for required-field validation (even with reqd=1), that adjacent required Data fields still validate and raise frappe.ValidationError when missing, and that Page Break maps to a no-value Frappe fieldtype with mapped fieldtype "Tab Break".
Integration tests: persistence and DocType sync
forms_pro/tests/test_page_break.py
Integration tests confirm forms save with a Page Break field and that syncing to the linked DocType creates a field with fieldtype "Tab Break".

Sequence Diagram(s)

(omitted)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly Related PRs

Poem

🐇
I hop a break between the fields, so neat,
A silent tab where form and visuals meet,
No value kept, no validation plea,
A gentle gap — a rabbit's page of glee.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 30.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: adding a new Page Break field type for multistep forms.
Description check ✅ Passed The description covers the key changes and includes a test plan, but is missing explicit confirmation of pre-commit and yarn typecheck completion required by the template.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/page-break-multistep

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
forms_pro/tests/test_page_break.py (1)

8-50: ⚡ Quick win

Consider strengthening assertions to verify DocType sync.

The test currently only asserts that "Page Break" appears in form.fields after reload (line 50). While this confirms form-level persistence, it doesn't verify that the Page Break field synced correctly to the linked DocType with the expected HTML fieldtype and <hr> options—unlike test_page_break_syncs_as_html_to_linked_doctype which does verify the sync contract.

Consider adding assertions similar to lines 68-72 in the second test to confirm the full persistence chain in this multi-field scenario as well.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@forms_pro/tests/test_page_break.py` around lines 8 - 50, The test
test_form_with_page_break_saves only checks that "Page Break" exists in
form.fields after reload; enhance it to also verify the linked DocType sync by
locating the generated DocType for the form (after form.save() / form.reload())
and asserting that the corresponding field was created there with fieldtype
"HTML" and options "<hr>" (mirror the assertions in
test_page_break_syncs_as_html_to_linked_doctype). Update the test to fetch the
linked DocType (using the same lookup used in the other test), find the field by
fieldname (e.g., "step_2"), and assert its fieldtype and options match the
expected synced values.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@forms_pro/tests/test_page_break.py`:
- Around line 8-50: The test test_form_with_page_break_saves only checks that
"Page Break" exists in form.fields after reload; enhance it to also verify the
linked DocType sync by locating the generated DocType for the form (after
form.save() / form.reload()) and asserting that the corresponding field was
created there with fieldtype "HTML" and options "<hr>" (mirror the assertions in
test_page_break_syncs_as_html_to_linked_doctype). Update the test to fetch the
linked DocType (using the same lookup used in the other test), find the field by
fieldname (e.g., "step_2"), and assert its fieldtype and options match the
expected synced values.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 77184cf1-2c0f-4988-92fa-a547e859caeb

📥 Commits

Reviewing files that changed from the base of the PR and between 6155a26 and 3948c51.

📒 Files selected for processing (5)
  • forms_pro/api/submission/test_submission_validation.py
  • forms_pro/forms_pro/doctype/form_field/form_field.json
  • forms_pro/forms_pro/doctype/form_field/form_field.py
  • forms_pro/tests/test_page_break.py
  • frontend/src/types/FormsPro/form_field.types.ts

Tab Break is a native Frappe layout field that renders proper tabs in
Desk view, replacing the raw HTML <hr> workaround.
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
forms_pro/forms_pro/doctype/form_field/form_field.py (1)

59-82: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Update the auto-generated DF.Literal union to include Page Break.

The runtime map supports "Page Break", but the TYPE_CHECKING fieldtype literal list does not. This creates a cross-layer type contract mismatch (editor/type-check errors despite valid runtime value). Please regenerate this block so "Page Break" is present in the union.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@forms_pro/forms_pro/doctype/form_field/form_field.py` around lines 59 - 82,
The DF.Literal type list for the fieldtype attribute is missing "Page Break",
causing a type-check mismatch; update/regenerate the DF.Literal union used by
the fieldtype variable (the literal block assigned to fieldtype in
form_field.py) to include "Page Break" alongside the other entries so the
TYPE_CHECKING literal matches the runtime map.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@forms_pro/forms_pro/doctype/form_field/form_field.py`:
- Around line 59-82: The DF.Literal type list for the fieldtype attribute is
missing "Page Break", causing a type-check mismatch; update/regenerate the
DF.Literal union used by the fieldtype variable (the literal block assigned to
fieldtype in form_field.py) to include "Page Break" alongside the other entries
so the TYPE_CHECKING literal matches the runtime map.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 07154101-4eaa-42aa-be7f-dd4dd3ec8d6b

📥 Commits

Reviewing files that changed from the base of the PR and between 3948c51 and ef5c4cc.

📒 Files selected for processing (3)
  • forms_pro/api/submission/test_submission_validation.py
  • forms_pro/forms_pro/doctype/form_field/form_field.py
  • forms_pro/tests/test_page_break.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • forms_pro/tests/test_page_break.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant