Skip to content

Add prompt option to select fields in l_ui_form - #87

Merged
thomasgallagher merged 2 commits into
mainfrom
add-select-prompt-option
May 19, 2026
Merged

Add prompt option to select fields in l_ui_form#87
thomasgallagher merged 2 commits into
mainfrom
add-select-prompt-option

Conversation

@thomasgallagher

Copy link
Copy Markdown
Collaborator

Allows passing prompt: "Choose..." on :select field configs, shown as the first option and only selectable when no value is set. Suppresses the default blank option when set.

Allows passing prompt: "Choose..." on :select field configs, shown as
the first option and only selectable when no value is set. Suppresses
the default blank option when set.
@claude

claude Bot commented May 19, 2026

Copy link
Copy Markdown

Review

Adds a prompt: option for :select fields in l_ui_form, shown as the first (placeholder) option and only selectable when no value is set. When prompt: is provided, the default include_blank: true is suppressed.

Issues

Severity File Line(s) Description
MEDIUM app/helpers/layered/ui/form_helper.rb 37-38 prompt and include_blank are not excluded from the extras computation, so they land in extras and are deleted inside the :select branch - which is correct. However, if either key is accidentally passed on a non-select field type, they silently pass through as raw HTML attributes (e.g. prompt="foo" on a text input). This was already possible for any unknown key before this PR, but prompt is now a documented, user-facing option that increases the likelihood of this mistake. Consider adding :prompt and :include_blank to the exclusion list in form_helper.rb and reading them from config directly in _field_input.html.erb instead - consistent with how :collection and :placeholder are handled.

Verdict

🟧 Ship (with known minor issue) - Core logic is correct for the happy path; the extras-passthrough concern is a pre-existing pattern and the practical risk is low.

Treat them like :collection and :placeholder so they never fall through
to extras and render as raw HTML attributes on non-select field types.
@claude

claude Bot commented May 19, 2026

Copy link
Copy Markdown

Review of PR #87 - Add prompt option to select fields in l_ui_form

This PR adds a prompt: option to :select field configs in l_ui_form, and canonicalises include_blank: alongside it (previously extracted ad-hoc from extras in the partial).

The logic is correct throughout: include_blank defaults to true only when neither include_blank nor prompt is explicitly supplied; both are excluded from extras before the Rails select call so they cannot leak as HTML attributes; and the prior extras.delete(:include_blank) behaviour is preserved in effect. Documentation, changelog, and dummy-app examples are all consistent with the implementation.

Ship

@thomasgallagher
thomasgallagher merged commit cd515d7 into main May 19, 2026
4 checks passed
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