Is It Possible To Pass An Extra Parameter To A Form Action?
I'm trying to do this:
Here's the action:
I keep getting the following errors on the "action" of the form:
Type 'Action<[userId: string], void>' is not assignable to type 'string | SerializableAttributeValue | undefined'.ts(2322)
The expected type comes from property 'action' which is declared here on type 'FormHTMLAttributes<HTMLFormElement>'
(property) JSX.FormHTMLAttributes<HTMLFormElement>.action?: string | JSX.SerializableAttributeValue | undefined
2 Replies
action={deleteUser(userId)}
will immediately execute that function and set the return value as the attribute, so I don't think that is what you are looking for.
I think I saw once on a stream action={deleteUser.with(userId}
but I can not seem to find documentation on it.
found it https://docs.solidjs.com/solid-router/reference/data-apis/action
A with method can be used when typed data is required. This removes the need to use FormData or other additional hidden fields. The with method works similar to bind, which applies the arguments in order.
Thanks! I'll give that a try.