brutusin / json-forms

JSON Schema to HTML form generator, supporting dynamic subschemas (on the fly resolution). Extensible and customizable library with zero dependencies. Bootstrap add-ons provided
http://brutusin.org/json-forms
Apache License 2.0
607 stars 168 forks source link

readOnly and default is not available at item of array #84

Closed baixiyang closed 7 years ago

idelvall commented 7 years ago

can you provide an example?

baixiyang commented 7 years ago

it did well in http://brutusin.org/json-forms/,but failed in master code 。here is my test data { "type": "array", "items":{ "type":"object", "properties":{ "a":{ "type":"string", "readOnly":true, "default":"asdf" } } } }

idelvall commented 7 years ago

you need to specify initial data

idelvall commented 7 years ago

I see your point, using "default"... I will work on it

idelvall commented 7 years ago

As far as i can see, it's working properly. Maybe you are inputting invalid initial data?

baixiyang commented 7 years ago

I debug to this line, initialValue is an empty object. but in http://brutusin.org/json-forms/ initialValue is null. if (typeof initialValue !== "undefined" && initialValue !== null) { value = getInitialValue(id); } else { value = s.default; }

baixiyang commented 7 years ago

oh ,I knew the reason ,because I pass an initial data bf.render(container, {});

baixiyang commented 7 years ago

I'm sorry to trouble you , thank you so much!

idelvall commented 7 years ago

no trouble at all!