-
-
Notifications
You must be signed in to change notification settings - Fork 10
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
Add support for sparseIndex
#48
Comments
I am actually not sure if i like this. It manipulates the result in a way that it cannot be restored with fromJson when you have activated this option. It's basically "Manipulating the form input names during toJson to fix the applications code when the form is changed". In your case, your app is responsible to correctly rename form input names after manipulating the form. |
Yes, agree. When DB row, for example, has 3 items: i1, i2, i3. It is very important to keep the order. If user put the value into i2 it is important to store that value into the second column. Another example with static IDs is when we put real IDs into the name, eg.
From the example above you can see that for company1 we can not add phone with index 34. It is already taken by the phone for company 2. But lets take into account other cases when the order it not important. Lets take DB as at the previous example. We did GraphQL query to DB and it returns the next data structure:
This is flattened into the HTML form with input's names like this:
And onto the form we can delete phone with ID 34 (index 0 at the data structure) and add as many phone as we want, eg. 50 phones. And this should be transformed into the same data structure recognizable by GraphQL
No ID means that phone 8 and phone9 will be created. If there is no such thing as |
I have exactly the same things in many of my applications and in my opinion it is exactly what the app need to deal with... Not an external Form Reader library. For example 1: One time we need it the same as you, an array. So we just do write input names starting from 0 upwards. For example 2: Another time we have almost the same as example 1, but we do not rename existing inputs. We just remember the highest used index and if we add new items, we add them with highest index + 1. So you never come in the situation that the same index is used twice. We do not get an array then but that is expected. For example3: Another time we do not want an array, we have real database ids in the indexes, like You see, all cases an app need should and can be done by the app and it's not a thing for this library to fix apps behaviour. I don't really see |
Is your feature request related to a problem? Please describe.
Sometimes forms are dynamic. Elements could be added or deleted. To same computing power and simplify solution
we can keep indexes as is.
Here is how data looks before the fix:

You can notice
objects
and that0
item was deleted bytrash
button.Describe the solution you'd like
Here is expected structure we got after the fix:

The text was updated successfully, but these errors were encountered: