Skip to content

Document how to build a select whose options change - #88

Closed
KamilSztandur wants to merge 1 commit into
mainfrom
select-options-workaround
Closed

KamilSztandur wants to merge 1 commit into
mainfrom
select-options-workaround

Conversation

@KamilSztandur

@KamilSztandur KamilSztandur commented Sep 20, 2026

Copy link
Copy Markdown
Collaborator

Problem

The built-in select has a fixed list of options. There is no way to change it after the field is created. Common case: the list of instructors depends on the chosen aircraft, or the list of cities loads once the country is known. People hit this and read it as a missing feature.

We do not want to change the package here. A select over a fixed list is the model, and making options part of the field state is a bigger decision. What was missing is a documented way to do it yourself.

Solution

Docs only, no code change. A new section in the custom-controllers page shows a complete controller built on AdvancedFieldController<V?, E> with its own mutable options list and a setOptions method. When the selected value is no longer on the new list, it is cleared without counting as a user edit, so an untouched field shows no error until submit, and a field the user had picked from shows "required" right away. The section also warns that membership is checked with ==, so an option deserialized from the server is not the same object as the one on the list.

In this PR

  • New section "A select whose options change" in docs/fields/custom.mdx, with the full controller and the == warning.
  • A pointer from the single-select docs, a new FAQ entry, and the same controller in SKILL.md.

The controller from the docs was run against the package in a throwaway test before writing it up.

🤖 Generated with Claude Code

The built-in select keeps its options final on purpose. For a list that
depends on another field or on a request, document the workaround: a
short controller on the concrete base class with a mutable list, a
setOptions that prefill-clears a value no longer on it, and the ==
membership trap. In the custom-controller page, the fields index, the
FAQ and the skill.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@KamilSztandur KamilSztandur changed the title Docs: a select whose options change, as your own controller Document how to build a select whose options change Sep 20, 2026
@KamilSztandur

Copy link
Copy Markdown
Collaborator Author

Closed: the changing options list is the real gap and gets fixed in the package instead. New PR follows.

@KamilSztandur
KamilSztandur deleted the select-options-workaround branch September 20, 2026 19:42
@github-actions

Copy link
Copy Markdown

Docs preview: https://advanced-forms-qjwz6d86t-leancode.vercel.app

Built from 25c0558; the landing page is at /, the docs under /docs.

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