- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
how to add enum in templates , its not showing combo box for templates #473
Comments
These enum dropdowns are a feature that you can use by providing a JSON Schema enumeration, so you could use it in combination with a template. |
var schema = {
"title": "Example Composite Schema",
"oneOf": [
{
"type": "object",
"properties": {
"enumerable_prop": {
"type": "string",
"enum": ["first", "second", "third"]
}
}
},
{
"type": "array"
}
]
};
var options = {
name: 'UconnectMessage',
schema: schema,
templates: [
{
text: 'text',
title: 'Insert a Message',
className: 'any',
field: 'notify,
value: {
enumerable_prop:null
}
} Can you give an example, I tried this , its not showing dropdown |
Here you go: |
Can json be an object instead? |
yes. just play around with it and you will see |
I tried and it didn't work |
Keep trying :) You will have to adjust both JSON and JSON schema, these need to be aligned with each other. |
No luck yet
|
I think the difficulty here is that the enum dropdown only works when the JSON matches the JSONSchema, whilst a template can be inserted everywhere. In your example code the enum for |
I didn't get you |
The schema that you post:
will only create a dropdown for the field
It will NOT create a dropdown not for nested objects like here:
if you need that, you will need to adjust your JSON Schema to have the definition of |
I have followed this conversation and tried everything you suggested, but I can not get a dropdown to show up anywhere but on the top level of the schema for an enum property like gender.
Do you have plans to make dropdown available on any level? |
@ortrud have you tried the example that I posted here? http://jsbin.com/ciqifub/edit?html,output There is no relation between jsoneditor and json-editor except that they are both editors for JSON :) If your json schema defines enums on any level, then JSONEditor will display them on any level - that's a matter of how you define your json schema. |
Hm, that's odd. Will look into it, thanks for reporting @SteveNeithardt. |
I think this issue is fixed via #624, will close it now. If there is still an issue please let me know. |
Hi @josdejong , I'm still running into this issue (or a similar one) in the current version (5.32.4) but only in the specific case where my schema has an object with additionalProperties having an enum. Here's an example: https://jsbin.com/vuyabuyiji/edit?html,output For the error to show up you have to add additional properties under the "testObj" object. As you can see in this example, the validation works, telling me I have to choose one of the enum values, but the combobox/select does not appear for the addtional properties. Thank you for looking into it 😄 |
@chriscarreau thanks for reporting (with a reproducible jsbin). Not sure, but I think the enum dropdowns don't (yet) reckon with |
Someone interested in looking into rendering an |
I was wondering if dropdowns for schemas with additionalProperties have been addressed yet?
|
Sadly it hasn't :( |
Thanks for checking 👍 . So we still have to do some debugging here. |
* Fixed issue #473. Enum works properly now * Fixed issues with lint rules
This should be fixed now in If not fixed, please re-open this issue again. |
* Fixed issue josdejong#473. Enum works properly now * Fixed issues with lint rules
No description provided.
The text was updated successfully, but these errors were encountered: