Skip to content

Add a file input component that works with forms #7980

@zshuzh

Description

@zshuzh

Provide a general summary of the feature here

I'm building a form that includes a few sections that require file uploads. It would be nice if I could use the existing form API to handle this scenario. I found this discussion that covers this topic — has there been any progress made since then? If not, and if there's still interest in implementing this, I'm happy to give it a go.

🤔 Expected Behavior?

<Form validationErrors={errors} onSubmit={onSubmit}>
  <TextField name="name">
    <Label>Name</Label>
    <Input />
    <FieldError />
  </TextField>
  <FormField name="files">
    <Label>Files</Label>
    <Input />
    <FieldError />
  </FormField>
  <Button type="submit">Add</Button>
</Form>

😯 Current Behavior

The FileTrigger component is currently not composable with the Form component.

💁 Possible Solution

My current best guess is that this would involve:

  1. creating a FormField component analagous to TextField and NumberField
  2. extending the Input component to be composable with FormField

I'm unsure how to tackle 2. as the current implementation of file upload in FileTrigger doesn't just use <input type="file" />. Would appreciate any input on this problem!

🔦 Context

n/a

💻 Examples

No response

🧢 Your Company/Team

No response

🕷 Tracking Issue

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions