In your *config.schema.json file, If you define an element to have an "enum" property with a list of values:
...
"myField": {
"type": "integer",
"enum": [
1,
0
]
},
...
the json-forms library will render the resulting form control as a "select" type with "option" elements for each of the "enum" values.
In the rendered form, if you change the select's value (and then save the form), although a "change" event it emitted, it's not currently observed, and the changed to value is not saved.
The form control event listener code in "spalp-json-form-builder.js":
$(jsonFormId).on('change', 'input', event_data, function (event) {
updateJsonFormElementData(event.data);
});
is only listening to "change" events in "inputs". If you update this to also listed to "select" controls, by adjusting the selector:
$(jsonFormId).on('change', 'input, select', event_data, function (event) {
updateJsonFormElementData(event.data);
});
the value is then correctly saved when the form save is done.
A further issue though, related to this, is that when you reload the form, json-forms library renders the generated select with the first "option" element selected, which is possibly not the value stored in the underlying data. So it looks like some further work needs to be done, after the generated form has been rendered, to ensure that any "select" control values match the underlying data.
Comments
Comment #2
alex_sansom commentedComment #3
alex_sansom commentedI've created a pull request that should address the issue(s) mentioned above:
https://github.com/Capgemini/spalp/pull/48
Comment #4
alex_sansom commentedComment #6
alex_sansom commentedThis made it into Beta 9 version of the module.
https://www.drupal.org/project/spalp/releases/8.x-1.0-beta9