-
-
Notifications
You must be signed in to change notification settings - Fork 73
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
Provide field order in JSON Schemas from @types endpoint #108
Comments
We ran into that as well. We have two options:
I'd go with 1 if possible. @lukasgraf @ebrehault opinions? |
That's part of the things JSON Schema does not address (because it focuses on schemas, not on forms). In angular2-schema-form, I have decided to use an I think it is a more solid approach than assuming the fields will be in the right order in We have a similar solution for fieldset by the way. |
I like choice 1 better, but some quick googling turns up a few sources saying one shouldn't rely on JSON object properties being ordered, so yeah, I guess we shouldn't. @ebrehault I guess you mean something like this for fieldsets:
With fieldsets like that, do we really need a separate |
Yeah, exposing an API that implies that keys in JSON objects are order is something we should avoid (that is, for any order that is actually relevant to the data - controlling the order of keys with the purpose of making it convenient to read for humans (list id and title early, stable sort order) is something different). When I used JSON schema for something else in our own projects and needed this, I went exactly with the solution that @ebrehault described (I went with So I prefer 2. |
@davisagli having a separate order field is useful for forms without fieldset, but I agree having |
I would consider a form without any explicitly declared fieldsets to contain one fieldset, the default fieldset. But if you disagree and want to support listing field order both at the schema level and within fieldsets, then I agree it's good to be consistent and call it |
Oh, sorry, I didn't mean I want to support field ordering at schema level and within fieldsets at the same time. I just meant schema level ordering is useful when we do not have any fieldset declared (else, schema level ordering should obviously be ignored or not allowed). |
We also discussed this again at the Beethoven Sprint: At this point, I'm leaning towards the style @davisagli outlined above: Always include a toplevel "fieldsets": [
{
"name": "default",
"label": "Default",
"fields": ["title", "description", "..."]
},
{
"name": "address",
"label": "Address",
"fields": ["fistname", "lastname", "..."]
}
] No need to track field order separately, both the order of fieldsets and their individual fields would be well defined that way. If no explicit Field moves as indicated by /cc @ebrehault |
Solved in #237 |
/cc @ebrehault
The text was updated successfully, but these errors were encountered: