-
Notifications
You must be signed in to change notification settings - Fork 556
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
Include value even if not in enum so legacy values not overidden #36
Comments
Hi @Anthropic, In your proposal, what happens when the form gets submitted with what you call a legacy value?
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 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 One thing I would do differently is that I would not use a property I am not really sure this possibility needs to be supported by JSON Form. It sounds rather specific. Do others have similar needs? |
@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. |
Closing as there is no activity on this issue. Please reopen a new one if needed. |
Can I suggest that there be an alteration to allow forcing a value into an enum for display perhaps with a format like the following to allow styling to illustrrate its origin:
So if form has legacyClass: "{{class name}}" as below:
And it is passed value: {enemies:"ninja"} which isn't in the enum as in the example above, then it could be added to the enum list and set as selected with output along the lines of:
Where I work we are absolutely not allowed to overwrite legacy information without good reason. So I need to make sure it is included in the drop down and flagged as "historic", but I can add that label in css if the value was there with an appropriate css style.
The text was updated successfully, but these errors were encountered: