Open adam-clarey opened 8 years ago
Thank you for report. can you give a json schema to reproduce the problem you described?
I've created this on the playground which mimics our problem. Our CMS IrisJS allows users to create complex entities via a UI so our forms are auto-generated quite a lot. In the below example, the default value in the textbox says 'letmein[0]" instead of "letmein[1]"
{
"schema": {
"author":{
"type":"array",
"title":"Users",
"expandable":true,
"default":[ { name:"letmein[1]"} ],
"description":"",
"items":{
"type":"object",
"properties": {
"name":{
"type" : "text"
}
}
}
}
},
"form": [{
"key":"author",
"type":"array",
"items":[{
"type":"fieldset",
"items":[{
"type":"text",
"autocomplete":{ "source":"/entity-reference/user/username" },
"key":"author[].name",
"title":"Username/Email",
"description":"" }]
} ]
}]
}
Just committed a workaround patch.
We have found that if you have a textfield within a fieldset and the default value is something like:
sometext[1]
When the form is rendered, line 2864:
changes the value in the textfield to:
sometext[0]
This is clearly a bug. I don't see any reason why jsonform should be altering the values in fields.
The comment above that line is:
// Note applying the array path probably doesn't make any sense, // but some geek might want to have a label "foo[].bar[].baz", // with the [] replaced by the appropriate array path.
Which doesn't make much sense, he references changing the label but its actually changing the field value. It also only seems to be there for some odd edge-case.
As this is a bug that is hampering our project, should i submit a patch to remove the line I mentioned above? It seems to be a clear bug