Skip to content

(in vue-vanilla) EnumControlRenderer.vue (and EnumOneOf...) always sets String vALUE in Data Json #2450

@bpzebra

Description

@bpzebra

Describe the bug

I have this field in my schema:
“land”: { “title”: “Land”, “type”: “integer”,
“oneOf”:[ {“const”: 19, “title”: “Deutschland” },
{“const”: 20, “title”: “Frankreich” } ]
},
but when i select one entry of the drop down list, i get a String of the integer in my json-object:
“land”: “19”,

so an error always occurs: “must be integer must match exactly one schema in oneOf”

this happens in EnumOneOfControlRenderer and is the same in EnumControlRenderer:
target.selectedIndex === 0 ? undefined : target.value // << this is always stringified

Expected behavior

an integer value should be set in the json-objekt
“land”: 19,

Steps to reproduce the issue

open a jsonform with an enum of type integer in the jsonschema and select a value.

Screenshots

No response

Which Version of JSON Forms are you using?

v3.5.1

Package

Vue Vanilla Renderers

Additional context

@Sirix wrote in the forum: ""
if you get a string in the data, then this means the renderer dispatched the wrong data. It should use the const of the schema it is handed over, instead it’s likely using the value from the input element it is rendering which seems to stringify them.
Here the actual options should be used, instead we use the value of the DOM element. Feel free to open an issue and contributing a fix if you’d like
""
i helped me wirh this peace of code:
target.selectedIndex === 0 ? undefined : ( Number.isNaN(target.value) ? target.value :Number(target.value) )

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions