Skip to content
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

Does it support keys with dot annotations? #262

Closed
lisss opened this issue Feb 23, 2015 · 8 comments
Closed

Does it support keys with dot annotations? #262

lisss opened this issue Feb 23, 2015 · 8 comments

Comments

@lisss
Copy link

lisss commented Feb 23, 2015

I use complex keys with dot annotations (e.g. "foo.bar") in JSON schema, and the form doesn't show the data from the model in such fields. Is it supported and how make it working then?

Thanks

@Dervisevic
Copy link
Contributor

Check out the examples page http://textalk.github.io/angular-schema-form/examples/bootstrap-example.html and switch to "complex keys" in the dropdown for an example on how to use it. Hope that helps.

@lisss
Copy link
Author

lisss commented Feb 24, 2015

So, did I catch it clear - the keys with dot notation should be used in square brackets in the form JSON, and it only works with Angular 1.3.x?

@Dervisevic
Copy link
Contributor

Oh sorry, i just reread you question. Dot notation is supported out of the box and is the standard way that ASF works, i was thrown off when you wrote complex keys as that is what we call when you use hyphens, brackets special chars etc. Dot notation only supports standard letters etc.

Could you post your schema/form/model so we can see how you use it, it may just be a mismatch problem or you do actually need to use the bracket support, so yeah post it and we'll see.

@lisss
Copy link
Author

lisss commented Feb 24, 2015

It's just a example piece of it but it should show the idea:

{
"model": {},

"schema": {
        "type": "object",

        "properties": {
            "kiuwan.agent": {"type": "string", "title": "Agent"}
        }
},
"form": [{"key": "kiuwan.agent", "placeholder": "Some placeholder"}]

}

@Dervisevic
Copy link
Contributor

Ah yes, then you need complex keys, I'm not actually sure how it's used, maybe @davidlgj or @mike-marcacci can give further insight.

@davidlgj
Copy link
Contributor

Hi @lisss,

yeah it's the complex keys you need, the basic trick is that whenever you have a .,- or any other character that wouldn't be valid JS code, you use a "bracket notation".

So in your example that would be:

{
"model": {},

"schema": {
        "type": "object",

        "properties": {
            "kiuwan.agent": {"type": "string", "title": "Agent"}
        }
},
"form": [{"key": "['kiuwan.agent']", "placeholder": "Some placeholder"}]

}

The documentation on this is lacking though :)

@lisss
Copy link
Author

lisss commented Feb 26, 2015

Yup, that's the way I supposed it to work but was unsure. (it still doesn't work in our project as we use Angular 1.2 but at least it's now more clear). Closing the issue, many thanks for responses.

@lisss lisss closed this as completed Feb 26, 2015
@mike-marcacci
Copy link
Contributor

Hey all! Sorry for the delayed response. @lisss, because complex keys need to use bracket notation in the angular expressions:

// invalid
model.foo-bar.baz

// valid
modal['foo-bar'].baz

...and Angular 1.2.x has serious problems using bracket notation, schema form sticks to dot notations in 1.2, making complex keys (unfortunately) impossible. Angular first fixed this in a 1.3-rc build, but didn't have anything for 1.2.x. I'm now curious if a patch has been applied to the 1.2 fork (which I believe is still alive for people who have lots of IE8 users). If it has, schema-form could use bracket notation everywhere, and your problem would magically be solved :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants