Hey all,
I’m experimenting with the new Form component in Ignition 8.3 and I’m wondering how dynamic it can be.
I’ve got a table in SQL that stores field metadata for custom forms. Each record has things like the field name, label, whether it’s required, and a data type (string, numeric, boolean, etc.).
Ideally, I’d like to pull that information at runtime and build the form dynamically by generating the JSON structure for props.columns (or whatever property the Form it expects..I may not be doing this correct).
From what I can tell, the hierarchy looks like this:
columns → items → rows → items → widgets
and each widget can be a "type": "text", "number", "checkbox", etc.
So in theory, I could return something like:
[
{
"align": "stretch",
"justify": "start",
"items": [
{
"visible": True,
"rows": [
{
"align": "start",
"justify": "start",
"items": [
{
"visible": True,
"align": "start",
"enabled": True,
"justify": "start",
"items": [
{
"visible": True,
"align": "start",
"widgets": [
{
"visible": True,
"defaultValue": "",
"label": "test",
"type": "text",
"input": {
"suffix": "",
"placeholder": "test"
},
"style": {"marginBottom": "8px"},
"id": "test",
"validation": {
"constraints": {
"required": {"enabled": True}
}
}
}
]
}
]
},
{
"visible": True,
"align": "start",
"enabled": True,
"justify": "start",
"items": [
{
"visible": True,
"align": "start",
"widgets": [
{
"visible": True,
"defaultValue": "",
"label": "new one",
"type": "number",
"input": {
"suffix": "seconds",
"placeholder": ""
},
"style": {"marginBottom": "8px"},
"id": "new one",
"validation": {
"constraints": {
"required": {"enabled": True}
}
}
}
]
}
]
}
]
}
]
}
]
}
]
Then assign that list to:
self.getChild("Form").props.columns = myJson
But when I try this, nothing renders yet…
Has anyone successfully generated a form dynamically like this in 8.3? If so, what’s the correct structure or method to inject widgets into the Form component programmatically?
Any insight or examples would be awesome. Thanks!