Another interesting use case, we wanted to titleize all labels from the model key instead of defining every single one in the schema.
We came with this:
import VJsf from "@koumoul/vjsf";
import titleize from "@/helpers/titleize";
// Dirty inheritance from VJsf because TypeScript is not happy with inheriting
// from a 3rd party component.
export default {
...VJsf,
computed: {
...VJsf.computed,
// Render the label as the model key in titleized format.
//
// This will avoid duplicated definitions in the widget form schema and any
// odd titles can be explicitly set.
label () {
return this.fullSchema.title || (typeof this.modelKey === 'string' ? titleize(this.modelKey) : '')
}
}
}
Ignore the typescript hack (still working on that) but pay attention that I wanted to overwrite the default behavior for the label using a helper of mine.
Maybe a slot for the label would be more appropriate, wdyt?
Another interesting use case, we wanted to titleize all labels from the model key instead of defining every single one in the schema.
We came with this:
Ignore the typescript hack (still working on that) but pay attention that I wanted to overwrite the default behavior for the label using a helper of mine.
Maybe a slot for the label would be more appropriate, wdyt?