dohomi / react-hook-form-mui

Material-UI form components ready to use with react-hook-form
https://react-hook-form-material-ui.vercel.app
MIT License
533 stars 108 forks source link

Add support for HiddenElement #313

Open tstiemerling opened 5 days ago

tstiemerling commented 5 days ago

Duplicates

Latest version

Summary 💡

Would be nice to have support for HiddenElement or similar which is basically with some wrapper code so the value can be defined in the default form data and sent to the onSuccess callback along with other inputs. Right now I have to have some extra useState variables to handle this separately from the form data.

Examples 🌈

No response

sadik-malik commented 3 days ago

@tstiemerling, could you clarify your use case? I'm not entirely sure which default form data you're trying to pass to the onSuccess callback.

Also, I am not in favor of adding a deprecated component like MUI Hidden to react-hook-form-mui.

dantheother commented 3 days ago

I believe OP is probably asking about something that helps with input type=hidden, rather than CSS hidden, which is what the MUI Hidden was all about.

I've not tried to do this myself using react hook form, nor mui, so I can't speak to what extra functionality a library could offer here.

sadik-malik commented 3 days ago

Okay, then the following code can be used to register the field while keeping it hidden in the form.

<input {...register("test")} type="hidden"/>