Open bitofbreeze opened 1 year ago
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.
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.
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.