Comments (8)
Hi @Chris2m,
True. That's a limitation in current version. I don't have any good ETA for that feature. In the meantime, note that you may achieve a similar effect with the value
property. Granted, it's rather meant to convey a previous submitted object, not default values.
For instance, instead of this:
{
"schema": {
"arr": {
"type": "array",
"items": {
"type": "string",
},
"default": [
"blah",
"foo"
]
}
},
"form": [
"arr"
]
}
... you could do this:
{
"schema": {
"arr": {
"type": "array",
"items": {
"type": "string"
}
}
},
"form": [
"arr"
],
"value": {
"arr": [
"blah",
"foo"
]
}
}
from jsonform.
Hi @tidoust,
thanks for your response. I am aware of the value property for previously submitted values. Still, in my use case relying on default properties would be a really nice to have feature as I need to distinguish between default values and previously submitted values. I am using JSON Form to implement a configuration page for the backend of a web application.
Right now - building upon the current state of JSON Form - the only feasible solution seems to traverse the entire nested schema and find all the default values of type="array" and then mixin the previously submitted values which seems kind of hacky.
Let me know if I can be of any assistance in adding this feature.
Best,
Chris
from jsonform.
In above mentioned commit, it now support all level default values in the schema.
from jsonform.
It seems this is now implemented — please reopen if this is still an issue.
from jsonform.
Is this actually implemented / merged now? Seems like it still does not work on the latest main branch to use default values with arrays.
from jsonform.
It doesn't seem to work for me either
from jsonform.
@iphoneintosh @TrangPham yes, its implemented long time ago
else if (isSet(this.schemaElement['default'])) {
// the value is not provided in the values section but the
// default is set in the schemaElement (which we have)
this.value = this.schemaElement['default']
// We only apply a template if it's a string
if (typeof this.value === 'string') {
this.value = _.template(this.value, valueTemplateSettings)(formData);
}
show the schema
from jsonform.
I'm using a reference and my default is set in the definitions like so:
{
"TableColumnsToMatchOrderedListKwargs": {
"title": "TableColumnsToMatchOrderedListKwargs",
"type": "object",
"properties": {
"column_list": {
"title": "Column List",
"default": [
"vendor_id",
"pickup_datetime",
"dropoff_datetime",
"passenger_count",
"trip_distance",
"rate_code_id",
"store_and_fwd_flag",
"pickup_location_id",
"dropoff_location_id",
"payment_type",
"fare_amount",
"extra",
"mta_tax",
"tip_amount",
"tolls_amount",
"improvement_surcharge",
"total_amount",
"congestion_surcharge"
],
"type": "array",
"items": {
"type": "string"
}
}
},
"additionalProperties": false
}
}```
would my default still be picked up?
from jsonform.
Related Issues (20)
- 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
- How to show error after a control value is changed, HOT 1
- date / datetime formatting HOT 3
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.