Skip to content

Write a select without a size as a combo box (#396) - #419

Merged
jakejackson1 merged 3 commits into
gravitypdffrom
fix/396-select-combo-box
Sep 23, 2026
Merged

jakejackson1 merged 3 commits into
gravitypdffrom
fix/396-select-combo-box

Conversation

@jakejackson1

Copy link
Copy Markdown
Member

With useActiveForms, every <select> was written as a list box. Form::print_ob_select() set the Combo flag only when size was set and below 2, but Tag\Select keeps size only when it is above 1. So even size="1" never got the flag.

What changed

  • Form::print_ob_select() now follows HTML. A select is a combo box unless it is multiple or has a size of two or more rows. A multiple select is always a multi-select list box, whatever its size.
  • The Edit flag and the spellcheck exception now rely on that same combo test.
  • Tag\Select reads multiple as true whenever it is present, the way Input and TextArea treat their boolean attributes. Before this, a bare multiple parsed to '', empty() treated it as absent, and <select multiple> lost its MultiSelect flag. That was true even with size="3".

The static (non-active) rendering does not depend on the combo decision and is unchanged. Row height still comes from size alone, so <select multiple> with no size stays one row tall. HTML draws four rows there, but changing that would change the layout of existing documents.

Select /Ff bits
no size, size="1" Combo, DoNotSpellCheck
size="4" DoNotSpellCheck
multiple, multiple size="3" MultiSelect, DoNotSpellCheck
editable Combo, Edit, DoNotSpellCheck
editable spellcheck="true" Combo, Edit
editable spellcheck="true" size="4" DoNotSpellCheck

Verification

  • tests/Mpdf/SelectFieldFlagsTest.php renders each of the cases above and decodes the field's /Ff. Before the fix, seven of the nine cases failed.
  • The page-break-avoid-forms snapshot is refreshed in its own commit. The only change in it is /Ff 4194304 → /Ff 4325376 on its two selects, which is the Combo bit, and its pages rasterise the same.
  • composer test passes: 3422 tests, 5 skipped. The snapshot group passes, and so do composer cs and PHPStan.

Interaction with #387

#387 draws combo boxes and list boxes differently, and plain selects will now take its combo-box path. I cherry-picked this fix onto fix/348-pdfa-active-forms and rendered selects with pdftoppm and Ghostscript. They were a plain select, one with no selected option, one at 20pt, size="3", and a bare multiple. In both renderers each combo box shows a single line with the selected option (or the first option when none is selected). The text is vertically centred and nothing below it is clipped. The one-row multiple list box shows only its highlighted option.

Fixes #396

🤖 Generated with Claude Code

jakejackson1 and others added 2 commits September 23, 2026 15:31
An active select got the combo box flag only when it carried a size
below two, but Tag\Select keeps the size only when it is above one, so
every select was written as a list box. HTML draws a select as a
drop-down unless it is multiple or given two or more rows, and the flags
now follow that rule. A bare multiple attribute was read as an empty
string and so ignored; its presence now makes the select multi-select.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…combo boxes

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Disable a select given a bare disabled attribute
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working create-upstream-pr

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A select without a size attribute is written as a list box rather than a combo box

1 participant