I’m working on converting a part of my application that allows 3rd party developers to create their own form. I was moving right along when I hit a roadblock that doesn’t make sense to me.
The concept itself isn’t groundbreaking in anyway . I unfortunately can’t share the code but I’m going to do my best to explain and show what I can. Where I’m stuck is with a nested generation.
controls: [
{
type: 'label',
label: 'Test Label',
id: 'label1',
value: '<span style="color:blue">Hello World!</span>'
},
{
type: 'string',
label: 'Test String Control',
id: 'string1',
value: 'Initial Value',
description: "test",
validation: {
required: true,
minLength: 2,
maxLength: 10
}
},
{
type: 'numeric',
label: 'Test Numeric Control',
id: 'numeric1',
defaultValue: 5,
description: "A numeric control",
validation: {
min: 5,
max: 20
}
},
{
type: 'string',
label: 'Test String Control 2',
id: 'string2',
value: 'Good one',
description: "test",
helpText: "This is some help text for the control.",
validation: {
required: true,
minLength: 2,
maxLength: 10
}
}]
This JSON will render this and all is well, everything works as intended.
Now if someone were to nest my groupCheckbox. The JSON now looks like this.
[
{
type: "groupCheckbox",
label: "Test Group Checkbox Control",
id: "groupcheckbox1",
controls: [
{
type: 'label',
label: 'Test Label',
id: 'label1',
value: '<span style="color:blue">Hello World!</span>'
},
{
type: 'string',
label: 'Test String Control',
id: 'string1',
value: 'Initial Value',
description: "test",
validation: {
required: true,
minLength: 2,
maxLength: 10
}
},
{
type: 'numeric',
label: 'Test Numeric Control',
id: 'numeric1',
defaultValue: 5,
description: "A numeric control",
validation: {
min: 5,
max: 20
}
},
{
type: 'string',
label: 'Test String Control 2',
id: 'string2',
value: 'Good one',
description: "test",
helpText: "This is some help text for the control.",
validation: {
required: true,
minLength: 2,
maxLength: 10
}
},
{
type: "groupCheckbox",
label: "Nested Group Checkbox Control",
id: "nestedgroupcheckbox1",
controls: [{
type: 'string',
label: 'Test String Control 2',
id: 'string3',
value: 'Good one',
description: "test",
helpText: "This is some help text for the control.",
validation: {
required: true,
minLength: 2,
maxLength: 10
}
}]
}
]
}
]
At runtime I am getting the ‘ couldn’t find a custom element with name “groupCheckbox-control”, did you forget to register it locally or globally?’ error when the first groupCheckbox tries to render itself. The control is registered globally otherwise the first level groupcheckbox wouldn’t render.
The primary rendering is done in a view that looks like this. The screencap above the migrated code working, it only fails in the nested case for some reason. Groupcheckbox is registered the same as the string and numeric with the difference being that group checkbox can render children.
<template repeat.for="control of controlSet.controls">
<au-compose component="${control.type}-control" model.bind="control"></au-compose>
</template>
And when the groupCheckbox is being rendered, it looks very similar
<template repeat.for="control of config.controls">
<div>
<au-compose if.bind="!control.hidden && control.isVisible" model.bind="control"
component="${control.type}-control"></au-compose>
</div>
</template>
