-
Notifications
You must be signed in to change notification settings - Fork 27
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
selectfieldset doesn't support customising the fields in the form #22
Comments
Not an issue, you can add extra information in the items. For reference, the following json does what I want: {
"schema": {
"choice": {
"type": "string",
"enum": [ "text", "cat" ]
},
"text": {
"type": "string",
"title": "Text"
},
"category": {
"type": "string",
"title": "Category",
"enum": [
"Geography",
"Entertainment",
"History",
"Arts",
"Science",
"Sports"
]
}
},
"form": [
{
"type": "selectfieldset",
"key": "choice",
"title": "Make a choice",
"titleMap": {
"text": "Search by text",
"cat": "Search by category"
},
"items": [
{
"key": "text",
"append": "today"
},
{
"key": "category"
}
]
},
{
"type": "submit",
"value": "Submit"
}
]
} |
Hmm, either there is am actual problem here or I'm missing something obvious. Hope it's the second option... Using object types to represent sub-fields. There's 2 options, put the definition under "items" and specify the key in dot-notation which means the sub-fields don't get their form definitions: "form": [
{
"items": [
{
"key": "text",
},
{
"key": "text.text1",
"append": "today"
},
{
"key": "text.text2",
"append": "tomorrow"
},
{
"key": "category"
}
]
}
] Or nest the sub-fields under the items, which means the fields get their definitions, but are shown twice as the parent is listed in the items too. "form": [
{
"type": "selectfieldset",
"key": "choice",
"title": "Make a choice",
"titleMap": {
"text": "Search by text",
"cat": "Search by category"
},
"items": [
{
"key": "text",
"items": [
{
"key": "text.text1",
"append": "today"
},
{
"key": "text.text2",
"append": "tomorrow"
},
]
},
{
"key": "category"
}
]
},
{
"type": "submit",
"value": "Submit"
}
] Complete examples. Reference fields in dot-notation under in the form items: {
"schema": {
"choice": {
"type": "string",
"enum": [ "text", "cat" ]
},
"text": {
"type": "object",
"properties": {
"text1": {
"type": "string",
"title": "Text1"
},
"text2": {
"type": "string",
"title": "Text2"
}
}
},
"category": {
"type": "string",
"title": "Category",
"enum": [
"Geography",
"Entertainment",
"History",
"Arts",
"Science",
"Sports"
]
}
},
"form": [
{
"type": "selectfieldset",
"key": "choice",
"title": "Make a choice",
"titleMap": {
"text": "Search by text",
"cat": "Search by category"
},
"items": [
{
"key": "text",
},
{
"key": "text.text1",
"append": "today"
},
{
"key": "text.text2",
"append": "tomorrow"
},
{
"key": "category"
}
]
},
{
"type": "submit",
"value": "Submit"
}
]
} Nest sub-fields in an {
"schema": {
"choice": {
"type": "string",
"enum": [ "text", "cat" ]
},
"text": {
"type": "object",
"properties": {
"text1": {
"type": "string",
"title": "Text1"
},
"text2": {
"type": "string",
"title": "Text2"
}
}
},
"category": {
"type": "string",
"title": "Category",
"enum": [
"Geography",
"Entertainment",
"History",
"Arts",
"Science",
"Sports"
]
}
},
"form": [
{
"type": "selectfieldset",
"key": "choice",
"title": "Make a choice",
"titleMap": {
"text": "Search by text",
"cat": "Search by category"
},
"items": [
{
"key": "text",
"items": [
{
"key": "text.text1",
"append": "today"
},
{
"key": "text.text2",
"append": "tomorrow"
},
]
},
{
"key": "category"
}
]
},
{
"type": "submit",
"value": "Submit"
}
]
} |
To custom sub items, you only need help of "customFormItems" with 2015-08-17 12:24 GMT+08:00 epitomus notifications@github.com:
Ulion |
I've never seen that before, but it works perfectly! I had to look through the jsonform.js file to figure out how it works as I couldn't find any documentation for it. For the curious, the way you use it is as follows (implementing the example above): {
"schema": {
"choice": {
"type": "string",
"enum": [ "text", "cat" ]
},
"text": {
"type": "object",
"properties": {
"text1": {
"type": "string",
"title": "Text1"
},
"text2": {
"type": "string",
"title": "Text2"
}
}
},
"category": {
"type": "string",
"title": "Category",
"enum": [
"Geography",
"Entertainment",
"History",
"Arts",
"Science",
"Sports"
]
}
},
"form": [
{
"type": "selectfieldset",
"key": "choice",
"title": "Make a choice",
"titleMap": {
"text": "Search by text",
"cat": "Search by category"
},
"items": [
{
"key": "text",
},
{
"key": "category"
}
],
},
{
"type": "submit",
"value": "Submit"
}
],
"customFormItems": {
"text.text1": {
"append": "today"
},
"text.text2": {
"append": "tomorrow"
}
}
} |
yes, it's not documented, only in my dev branch here, but also in some of 2015-08-17 13:20 GMT+08:00 epitomus notifications@github.com:
Ulion |
Really useful! Are there any other top-level directives like form and value? |
Hmm, |
probably no. if there is, it will in the playground examples. 2015-08-17 13:35 GMT+08:00 epitomus notifications@github.com:
Ulion |
then it's not related to customFormItems, must be the specific use case of please make an issue with full info. 2015-08-17 13:40 GMT+08:00 epitomus notifications@github.com:
Ulion |
If you create a customfieldset, you cannot have the fields present in the form section as they are created dynamically. If you do, it causes name clashes, and will also show the field all the time.
The text was updated successfully, but these errors were encountered: