Skip to content

Commit

Permalink
Adds support for schema default values inside other props, like objec…
Browse files Browse the repository at this point in the history
…ts or unions
  • Loading branch information
mikecmart committed Oct 17, 2024
1 parent 8c6cef4 commit bfcd4ad
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/protolib/src/components/EditableObject/Element.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,16 @@ export const getElement = ({ ele, icon, i, x, data, setData, mode, customFields
return target
}

if (!(target && target.hasOwnProperty(key))) {
var defaultValue = elementDef?.defaultValue
if (typeof defaultValue === 'function') {
defaultValue = defaultValue()
}

if (defaultValue != undefined) {
setFormData(key, defaultValue)
}
}
// Retorna el valor de ele.name o un valor predeterminado.
return target && target.hasOwnProperty(key) ? target[key] : '';
}
Expand Down

0 comments on commit bfcd4ad

Please sign in to comment.