Skip to content

fix(file_input): append [] to the name for multiple-file inputs - #23

Merged
mhenrixon merged 1 commit into
mainfrom
fix/file-input-multiple-array-name
Aug 12, 2026
Merged

fix(file_input): append [] to the name for multiple-file inputs#23
mhenrixon merged 1 commit into
mainfrom
fix/file-input-multiple-array-name

Conversation

@mhenrixon

@mhenrixon mhenrixon commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

Summary

Rails file_field parity: with multiple: set, the input name now gets [] appended (unless already present) — for the standalone component, the Plain variant, and the form builder path.

Without it, the browser collapses a multi-file selection into one scalar param, which a host app's params.expect(attr: []) silently discards — uploads no-op while the request returns success. This bit cosmos/yoga in production (zoolutions/cosmos#1997): the Sardinia gallery upload 302'd "updated successfully" having attached nothing.

Test plan

  • New spec/forms/file_input_spec.rb: single name untouched, [] appended when multiple, no double-append, builder path, Plain variant
  • Full suite: 181 examples, 0 failures

Summary by cubic

Fix multiple file uploads by appending [] to the input name when multiple is set, matching Rails file_field behavior. Prevents browsers from collapsing multi-file selections into a single param so apps receive an array.

  • Bug Fixes
    • Append [] to the name for multiple inputs in the component, Plain variant, and form builder.
    • Skip append when the name already ends with [].

Written for commit 2607d0b. Summary will update on new commits.

Review in cubic

Rails file_field parity: without the [] suffix the browser collapses a
multi-file selection into ONE scalar param, which a host app's
params.expect(attr: []) silently discards — uploads no-op with a success
response (bit cosmos yoga in production, Aug 2026). Applies to the
standalone component, the Plain variant, and the form builder path;
names already ending in [] are left alone.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 3 files

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

Comment thread CHANGELOG.md
@mhenrixon
mhenrixon merged commit 91287e0 into main Aug 12, 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