How to use HiddenField in Form for numeric value?

I know there is HiddenField and NumericField.
But I want both functionalilty.

I’m trying to pass userId in the form.

How to do that? Because HiddenField always return string not int

    <HiddenField
      name="userId"
      value={userId}
      validation={{ valueAsNumber: true }}
    />

Please do not pass user ids in form / graphql requests.

Instead use authentication and get the userId server side from the context.currentUser.id in your service.

That way no one can impersonate another user.

1 Like