Closed yaustar closed 10 months ago
You set the default
property for each element in the schema not on the surrounding object as you have done. For your example, you would set it as
Test.attributes.add('testObjects', {
type: 'json',
array: true,
schema: [{
name: 'foo',
type: 'entity',
default: null,
}, {
name: 'bar',
type: 'string',
default: '',
} ],
});
@kpal81xd Ah yeah, makes sense.
@yaustar I'm going to close this since it appears you specified the JSON attribute incorrectly. However, if you believe there's still a problem here, please let me know.
I guess there is still no way to specify default value for a whole JSON array? I guess this applies for any array-like attribute.
The idea (which wasn't communicated well in hindsight) is to be able to set a default array of values so when first added, it could look like this
kpal81xd's example sets the default values for each new added array element
Ahh yes, I understand now. Doing some testing using the main
branch and local engine flag in the editor indicates that it's working as outlined above.
Given:
It would be great if we can autofill the default values of a script type with these types rather than just have an array of 0