New intent to set the value of a single field #385
aaronadamsCA
started this conversation in
Ideas
Replies: 1 comment
-
I'm very glad to see that this now exists in const [field, form] = useField(name);
return (
<button
{...form.update.getButtonProps({
name,
value: "",
validated: true,
})}
>
Remove
</button>
); |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'd like to see a new
set
intent added that simply updates the value of a single field. I think this would essentially be a much simpler version of the existinglist
intents.Background
I want to build a robust file input component that uses proper Remix and Conform semantics. This turns out to be a big challenge!
My requirements for a "great" file input component are:
defaultValue
prop that represents an existing file ID/name, so the value can be preserved without changes (just like any other type of form field).The difficulty with this is that
<input type="file">
doesn't take adefaultValue
, so you also need<input type="hidden">
to send an unchanged original value back to the server, and some kind of UI to swap between the hidden input and the file input. Today the only real solution for this is client state.But if I could create a button whose intent was simply to clear an existing file name/ID from a field, e.g.
<button {...set(profile.picture, null)}>Remove</button>
, then presumably I could do this without needing any client state.Beta Was this translation helpful? Give feedback.
All reactions