Comments (3)
Hi @Anthropic,
In your proposal, what happens when the form gets submitted with what you call a legacy value?
- Should the schema be automatically adjusted to accept the incorrect value?
- Should the submission trigger an error because the schema is not respected?
Option 1. does not sound quite right. What good is a schema if the code can decide to change it on its own? If you expect the unexpected values, the best would be to define the field as a regular string
in the schema and to define the base enumeration in the form
part. I do not know whether the enumeration is going to work as-is if it is defined that way though (I haven't checked). The good part is that doing so lets us move from option 1 to option 2, as the schema does not need to be automatically adjusted anymore.
Option 2. can be implemented with a custom field, I think. In other words, there should not need to be any change to the core of the JSON Form library. Just take the code of the select
field type as basis to create a new extensibleselect
(or some better name) that would create the appropriate markup for you.
One thing I would do differently is that I would not use a property legacyClass
but rather a allowUndefinedValues
flag or similar. The generated markup would still mark the unknown values with a specific class undefined-value
for styling purpose. You would lose the ability to specify a custom class but would be more explicit about what you're trying to achieve.
I am not really sure this possibility needs to be supported by JSON Form. It sounds rather specific. Do others have similar needs?
from jsonform.
@tidoust ok I think you gave me an easier way (perhaps) to get the solution I am after!
If the schema was a plain string with no enum, then if I could define the enum at the form level using the already included titleMap field instead, it could allow for additions. In that way it could double as a suggestion list rather than a hard list were it set to text in the form definition perhaps.
I can imagine uses for a suggestion list on a form field beyond my current use case.
{
schema: {
enemies: {
title: "Scariest Enemy!",
}
},
form: [
{
key: "enemies",
type: "select",
titleMap: {
dragon: "The Dragon",
pirate: "Jack Sparrow",
alien: "ALF"
},
// template for undefined value label
undefined: "[legacy] {{value}}"
}
],
value: {
enemies: "ninja"
}
}
At the moment when I do the above I get a select box with nothing in it, if it could add the titleMaps values as options when no enum is defined, then my problem would be solved. :)
Obviously I could just add the option to the schema or titleMaps prior to initialising, but that doesn't feel right.
from jsonform.
Closing as there is no activity on this issue. Please reopen a new one if needed.
from jsonform.
Related Issues (20)
- How to add class on label tag HOT 4
- change the 'previously submitted values' from a variable. HOT 26
- Ace Type as Array HOT 10
- How to Map My Custom JSON Value to JSON Forms HOT 8
- titleMap in selectbox array HOT 4
- [Question] How to get the markup of the form programatically in JS without attaching it to a DOM element HOT 3
- How to make a valid json with a onChange function ? HOT 4
- Add custom field to fieldset HOT 2
- activeClass isn't applied correctly for schemas with defaults HOT 2
- How to build a stepper form HOT 4
- process change, just fyi.. all PRs against develop branch
- Expanded Fieldset + Default TabIndex set - Collapse issue (bug) HOT 4
- tabs-left not supported in bootstrap v3
- Hide submit button HOT 2
- How to escape slash in scope HOT 3
- Rendering fails if property name contains dots HOT 1
- Missing array brackets [] on array items when using a custom field type HOT 1
- Error: JSONForm does not yet support schemas that use the $ref keyword. See: #54" HOT 2
- Boolean options are always true HOT 5
- How to use this library with bundler HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jsonform.