Skip to content

fix(documents): render checkboxes checked — New/Used + all ~24 (P1)#209

Merged
arigatoexpress merged 1 commit into
mainfrom
fix/p1-doc-correctness
Jun 19, 2026
Merged

fix(documents): render checkboxes checked — New/Used + all ~24 (P1)#209
arigatoexpress merged 1 commit into
mainfrom
fix/p1-doc-correctness

Conversation

@arigatoexpress

Copy link
Copy Markdown
Owner

P1: checkboxes render checked (New/Used + all ~24)

From the holistic review. The New/Used election — the box Mark Willcott specifically flagged — and every other checkbox (wheels, insurance, tax-escrow, marital, own/rent, warranty single/double) rendered blank on generated packets.

Root cause (fill layer): the code wrote the literal "On", but pypdf checks a box only when handed the widget's exact on-state name with its leading slash. THO widgets use /1 (TMHA/TDHCA) or /Yes (creditapp), never /On. Verified empirically: "On", "1", and "/Yes" all render /Off; only /1 checks New_Yes.

Fix: fill_pdf_form now resolves each checkbox/radio value to the widget's real on-state from /_States_ before filling — one change covers all checkboxes; radio groups select the matching option by name. Templates + field_map untouched; pypdf stays 6.12.2.

Verification: tests/test_checkbox_rendering.py (resolver unit + New-checked-on-new-home + Used-checked-on-used-home). Full suite 1096 passed, ruff clean.

Mark Willcott review — the New/Used election (and every checkbox: wheels,
insurance, tax-escrow, marital, own/rent, warranty single/double) rendered BLANK
on generated packets. Root cause in the fill layer: it wrote the literal 'On',
but pypdf checks a box only when handed the widget's exact on-state name WITH its
leading slash. THO widgets use '/1' (TMHA/TDHCA) or '/Yes' (creditapp), never
'/On' — verified empirically that 'On'/'1'/'/Yes' all render /Off, only '/1'
checks New_Yes.

fill_pdf_form now resolves each checkbox/radio value to the widget's real
on-state from /_States_ before update_page_form_field_values (one fix covers all
checkboxes; radio groups select the matching option by name). Templates and the
field_map are untouched; pypdf stays 6.12.2.

New tests/test_checkbox_rendering.py (resolver unit + New checked on new-home +
Used checked on used-home). Full suite 1096 passed, ruff clean.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@arigatoexpress arigatoexpress merged commit b8c2969 into main Jun 19, 2026
2 checks passed
@arigatoexpress arigatoexpress deleted the fix/p1-doc-correctness branch June 19, 2026 23:31

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: aaf420f1c0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread tools/document_tools.py
Comment on lines +663 to +665
appearance_data = _resolve_checkbox_values(
appearance_data, _checkbox_field_states(reader)
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Resolve checkbox states before filling XFA

When generated XFA-backed forms are opened in Adobe Acrobat, Acrobat uses the XFA datasets that were already written by _fill_xfa(..., fill_data) before this resolver runs, so those datasets still contain the original On/Off checkbox values. I inspected the TMHA XFA checkbox definitions and their item values are 1/0, meaning the New/Used boxes can still render unchecked in the Acrobat/XFA path even though the AcroForm appearance is fixed for non-XFA viewers.

Useful? React with 👍 / 👎.

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