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

Hidden field value does not get submitted unless Field rendered #146

Open
bitofbreeze opened this issue Jan 14, 2023 · 2 comments
Open

Hidden field value does not get submitted unless Field rendered #146

bitofbreeze opened this issue Jan 14, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@bitofbreeze
Copy link

bitofbreeze commented Jan 14, 2023

I was very confused why this was happening for a while based on the docs that show that declaring the hidden fields with values in the Form props is enough.

It turns out when you use a custom form, you must write an instance of Field for the hidden inputs too. You can see in my repro that submitting with line 60 commented gives no value in the action for "hidden", but uncommenting it does. I wonder if this is intended behavior, and if so, if the docs can be clarified.

I don't understand why we even declare the hidden field in the props if you still have to write the Field JSX for it.

@darlantc
Copy link

I agree with you, this is annoying specially because it is hard to catch the problem when those hidden fields holds required values to submit the form.
It would be nice to have the hidden fields automatically pushed to the render tree for custom forms.

@noels
Copy link

noels commented Nov 9, 2024

I have also just run into this. Additionally, errors on hidden fields don't show as 'global' errors on the form. If I write a custom input like: https://remix-forms.seasoned.cc/examples/forms/custom-input I can display the errors, but I think it would be useful to just throw an exception if any hidden field fails validation so it is shown in the global errors. I think this is a better DX than wondering why your form failed to submit. I have tried on both main and the experimental branch, and the behaviour is the same.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants