fix(documents): render checkboxes checked — New/Used + all ~24 (P1)#209
Conversation
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>
There was a problem hiding this comment.
💡 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".
| appearance_data = _resolve_checkbox_values( | ||
| appearance_data, _checkbox_field_states(reader) | ||
| ) |
There was a problem hiding this comment.
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 👍 / 👎.
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/1checksNew_Yes.Fix:
fill_pdf_formnow 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.