-
Notifications
You must be signed in to change notification settings - Fork 54
Allow Complex (e.g., JSON) Default Property Values #417
Comments
By the way, here's how Umbraco correctly stores a picked form value: {"alias":"form","value":"{\r\n \"id\": \"397c9fbd642a4e2098487572fafe7338\"\r\n}"} My guess would be that the way this is stored is not how it's sent to the AngularJS directive. I would guess it converts the string value into a JSON object. I would further suspect that the reason this doesn't work with Archetype is that Archetype is setting this on the client side, which bypasses Umbraco's server-side JSON detection logic (i.e., it is passed as a string rather than as JSON). Haven't actually looked at the code though, so that's just a guess. The simplest solution I can think of would be to add a checkbox under the "Default Value" field that says "Treat Default Value as JSON?" Or maybe you could have a drop down that indicates the format of the default value (the initial value being "Plain Text", and another option being "JSON"). |
Actually Archetype already tries to parse the default values to JSON objects. Unfortunately there was an error in the subsequent value assignment, which forced the parsed object into a string. It's fixed, will be part of the next release. Please note that the JSON used for default values must validate with https://jsonlint.com/ - or in other words, must be valid for |
Reopening this until we have a new release. |
Fixed in v1.15.1 |
When adding a property to an Archetype fieldset, a default value can be specified:
That works OK when the value is a simple text value. However, it doesn't seem to work when it's a complex data type (in this case, a blob of JSON).
On a related note, would be great if this were a text area rather than a text line (that way, complex data that spans multiple lines can more easily be read).
FYI, the data type I'm trying to set a default for in this case is a Formulate form configuration picker.
The text was updated successfully, but these errors were encountered: