-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Description
Prerequisites
- I have searched the existing issues
- I understand that providing a SSCCE example is tremendously useful to the maintainers.
- I have read the documentation
- Ideally, I'm providing a sample JSFiddle, Codesandbox.io or preferably a shared playground link demonstrating the issue.
What theme are you using?
core
Version
6.0.0-beta-12
Current Behavior
Hi,
First, thank for your work on that package. It's an amazing library to work with 👏
Since 6 is not out yet, is there any possibility to make (array) field names compliant with "traditional" form submission (e.g. hitting a submit button and handling a good old POST browser form request)?
Take the "Array" example from playground and look at the field names, for example "listOfStrings", HTML is:
<input id="root_listOfStrings_0" name="root_listOfStrings_0" class="form-control" label="listOfStrings-0" required="" placeholder="" type="text" aria-describedby="root_listOfStrings_0__error root_listOfStrings_0__description root_listOfStrings_0__help" value="foo">
<input id="root_listOfStrings_1" name="root_listOfStrings_1" class="form-control" label="listOfStrings-1" required="" placeholder="" type="text" aria-describedby="root_listOfStrings_1__error root_listOfStrings_1__description root_listOfStrings_1__help" value="bar">
<!-- and so on -->
If you submit that form using a dummy submit button and check your payload, you will not get an array. Same goes for any other "array" fields (repeaters, etc.).
Expected Behavior
I would expect the form to be
<input id="root_listOfStrings_0" name="root_listOfStrings[0]" class="form-control" label="listOfStrings-0" required="" placeholder="" type="text" aria-describedby="root_listOfStrings_0__error root_listOfStrings_0__description root_listOfStrings_0__help" value="foo">
<input id="root_listOfStrings_1" name="root_listOfStrings[1]" class="form-control" label="listOfStrings-1" required="" placeholder="" type="text" aria-describedby="root_listOfStrings_1__error root_listOfStrings_1__description root_listOfStrings_1__help" value="bar">
<!-- and so on -->
I already know I could submit the data using JS as a workaround. But in my case, that is not an option because I'm rendering my RJSF form inside a already there "traditional" form (using a div
tag).
I tried to take a look at the code and submit a PR but I don't have a deep enough understanding of the codebase to make it work.
Note that setting a form name
will also imply that all fields will be prefixed by that name:
<form name="root">
<input name="root[firstName]" />
</form>
So in case multiple firstNames
are submitted:
<form name="root">
<input name="root[firstName][]" /> <!-- OR root[firstName][0] -->
<input name="root[firstName][]" /> <!-- OR root[firstName][1] -->
</form>
Let me know if I can help (a little guidance on where to look at might be welcome).
Steps To Reproduce
Check "Array" playground example.
Environment
- OS: Mac OS
- Node: 20.x
- npm: 11.x
Anything else?
No response