Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Select component with number types #180

Open
PHinett2 opened this issue Feb 14, 2024 · 3 comments
Open

Select component with number types #180

PHinett2 opened this issue Feb 14, 2024 · 3 comments
Assignees
Labels
question Further information is requested

Comments

@PHinett2
Copy link

I have been trying to modify the Select component from the playground to accept number or number[] values in both the value and options props, but i can't seem to get it to work unless I use strings for everything.

Is there a limitation that it must be string values, or could there be a way to allow number types too?

@fabian-hiller
Copy link
Owner

I think the main problem here is that HTML <select /> element does not allow us to capture values as numbers, only as strings. That's why Modular Forms probably doesn't do it either.

@fabian-hiller fabian-hiller self-assigned this Feb 14, 2024
@fabian-hiller fabian-hiller added the question Further information is requested label Feb 14, 2024
@PHinett2
Copy link
Author

Yes i presumed this was the case. I can work with this i suppose. Its just that i would need to convert the values back to number types before submitting them back to my rest api.

@fabian-hiller
Copy link
Owner

fabian-hiller commented Feb 14, 2024

If you are using Zod or Valibot to validate your form, you could use transform to transform the strings to numbers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants