Add a file-upload answer type to the form engine - #2136
Open
maebeale wants to merge 2 commits into
Open
Conversation
Registrants can now answer a form question by uploading a file (e.g. the post-event survey's photo-of-a-creation question). File-upload answers store their blob on the existing polymorphic Asset — the same attachment, content-type validation, and image/PDF display machinery story ideas use — so no migration is needed. Direct upload submits a signed blob id as a normal param, so the form stays non-multipart. Fixes #2109. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…d views Covers the new answer_type, its Asset-backed attachment, presence/skip behavior in FormAnswerValidator, blob attachment + filename storage + content-type rejection in PublicRegistration, and the answer-display partial's image preview + download link.
maebeale
marked this pull request as ready for review
August 9, 2026 23:58
Collaborator
Author
|
@jmilljr24 i'm building up to supporting the post-event survey and the daily surveys via callouts. they ask for people to upload a photo of their work, so that's why i'm angling to change our form answers to support uploads. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 suggested review level: 5 Inspect 🔬 new answer type wired through the model enum, submission service, validator, and 6 answer-display sites
Closes #2109
What is the goal of this PR and why is this important?
file_uploadanswer_typeso form authors can ask for a file (photo, PDF, doc).How did you approach the change?
Asset(FormAnswer has_one :asset, as: :owner) — the same attachment, content-type validation (Asset::ACCEPTED_CONTENT_TYPES), and image/PDF display machinery story ideas use. No schema change.fileinput wired to the existingfile_previewStimulus controller; JS streams the file to storage and submits a signed blob id as a normal param — so the form stays non-multipart and the existing params/validator flow is unchanged.PublicRegistrationwere folded into onepersist_answer, which attaches the blob for file fields and stores the filename insubmitted_answer(so text-only views/exports still read).shared/_form_answer_valuepartial: file answers show an inline image thumbnail (or a link for non-images) plus a download link; everything else is unchanged.FormAnswerValidatortreats a required file question as present/blank;Assetenforces the content type on attach.Anything else to add?