Skip to content

Fill in a form in the browser - #5

Merged
tannevaled merged 1 commit into
mainfrom
fill-forms
Aug 26, 2026
Merged

Fill in a form in the browser#5
tannevaled merged 1 commit into
mainfrom
fill-forms

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

A form is the one thing in a PDF meant to be changed by whoever receives it — and the one thing every other verb in this workbench would destroy, since rotating a page or laying two on a sheet rebuilds the document and a form is tied into one by object number in a dozen places at once.

So a form is filled in on the file itself: what was opened is kept, the values go into it, and what is saved is that file with the answers appended. A form saved here is still a form.

Built from the toolkit, nothing hand-drawn

Entry for a text field, CheckButton for a checkbox or a button, DropDown for a choice field, FormField for the label, ScrollView for a form longer than the window. A field the document locks is shown as a plain label — so somebody can read what it holds and see why they cannot type in it.

Each is bound to its field through the observable the widget already publishes. Nothing is copied per frame.

What the tests taught me

The first version of these tests called Field.SetText directly and passed — while three of the bindings had never once been executed. Coverage said so; the assertions did not.

They now dig the real widget out of the row and drive that:

entry := inputOf(t, s.form.row(s, field)).(*toolkit.Entry)
entry.SetText("Mozart")
if field.Value != "Mozart" { ... }

Which is the difference between proving the setter works and proving anything is wired to it.

100% statement coverage, go vet clean, js/wasm builds.

A form is the one thing in a PDF meant to be changed by whoever receives it,
and the one thing every other verb in this workbench would destroy: rotating a
page or laying two on a sheet rebuilds the document, and a form is tied into a
document by object number in a dozen places at once.

So a form is filled in on the file itself. What was opened is kept, the values
go into it, and what is saved is that file with the answers appended after it —
which is how everything that saves a form saves one, and which means a form
saved here is still a form.

The panel is built out of the toolkit's own widgets and nothing else: a box to
type in, a square to tick, a list to choose from, and a plain label for a field
the document says may not be changed — shown all the same, so somebody can read
what it holds and see why they cannot type in it. Each is bound to its field
through the observable the widget already publishes, so nothing is copied back
and forth every frame; a change arrives when it happens.

The tests drive the widgets rather than the setters behind them. Calling
Field.SetText from a test proves the setter works and says nothing about
whether anything is wired to it — and the first version of these tests did
exactly that, and passed while three of the bindings were never once executed.
@tannevaled
tannevaled merged commit 0e9168a into main Aug 26, 2026
2 checks passed
@tannevaled
tannevaled deleted the fill-forms branch August 26, 2026 16:44
tannevaled added a commit that referenced this pull request Aug 27, 2026
A form is the one thing in a PDF meant to be changed by whoever receives it,
and the one thing every other verb in this workbench would destroy: rotating a
page or laying two on a sheet rebuilds the document, and a form is tied into a
document by object number in a dozen places at once.

So a form is filled in on the file itself. What was opened is kept, the values
go into it, and what is saved is that file with the answers appended after it —
which is how everything that saves a form saves one, and which means a form
saved here is still a form.

The panel is built out of the toolkit's own widgets and nothing else: a box to
type in, a square to tick, a list to choose from, and a plain label for a field
the document says may not be changed — shown all the same, so somebody can read
what it holds and see why they cannot type in it. Each is bound to its field
through the observable the widget already publishes, so nothing is copied back
and forth every frame; a change arrives when it happens.

The tests drive the widgets rather than the setters behind them. Calling
Field.SetText from a test proves the setter works and says nothing about
whether anything is wired to it — and the first version of these tests did
exactly that, and passed while three of the bindings were never once executed.

Co-authored-by: David Delavennat <david.delavennat@free.fr>
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