Hidden Inputs

πŸ‘¨β€πŸ’Ό Great! Now when the user submits the form, this extra information will be available in the submission without the user needing to supply it. Well done!
πŸ¦‰ A common question here is whether you can supply complex data structures as hidden input values, and you definitely can. You can either provide multiple hidden inputs, or just stick JSON in your hidden input like so:
<input
	type="hidden"
	name="order"
	value={JSON.stringify({ sandwich: 'tuna' })}
/>
Then the backend could parse that JSON from the order form field. This can be very useful if you're using a library that doesn't render form elements, but you want to send the user's selections to the backend as a part of your form using your own form elements.
Login to get access to the exclusive discord channel.
  • βš›οΈFundamentals
    First Four Exercises are Free!
    Kent C. Dodds β—† πŸš€πŸ†πŸŒŒ:
    To make sure this shows up in the fundamentals thread. Isn't it exciting the first four exercises of...
    1 Β· 4 days ago
  • General
    Welcome to EpicReact.dev! Say Hello πŸ‘‹
    Kent C. Dodds β—† πŸš€πŸ†πŸŒŒ:
    Welcome to the first of many posts in the EpicReact.dev channel! Take a moment to introduce yourself...
    0 Β· 4 days ago