Skip to main content

Object

The Object component handles nested form structures, allowing users to add, modify, and manage items dynamically. This component supports nested objects and arrays, making it versatile for complex form data handling. It leverages Material-UI's components to provide a structured and organized user experience.

Schema

warning

Warning: Avoid using . (dot) in the name property as it can cause issues with nested field paths in the form state.

Examples of accepted naming conventions:

  • obj_item
  • objItem1
  • anyname
{
"name": "cart",
"meta": {
"displayType": "object",
"displayName": "Cart Items",
"readOnly": false,
"children": [
{
"name": "accessoreis",
"meta": {
"htmlProps": {
"allowDynamic": true
},
"displayType": "object",
"displayName": "Accessories",
"children": [
{
"name": "SKU_PHONE",
"meta": {
"validation": { "required": true },
"displayType": "text",
"displayName": "SKU Phone"
}
},
{
"name": "SKU_ADDRESS",
"meta": {
"validation": {
"required": false
},
"displayType": "textarea",
"displayName": "SKU Address"
}
}
]
}
}
]
}
}

Example Component



Form Data:
{}

Props

meta object

The meta object defines the display characteristics and behavior of the Object component.

NameDescriptionType
displayNameThe name to display as the section headerstring
htmlPropsProperties for HTML behavior, like allowDynamicobject
childrenArray of child fields contained within the Objectarray
displayTypeType of the field display, which is "object" in this casestring
readOnlyA readonly field is not editable and value cannot be changedboolean

Example JSON Structures

Nested Object

{
"name": "items",
"meta": {
"displayType": "object",
"displayName": "Items",
"htmlProps": {
"allowDynamic": true,
"allowAdd": true
},
"validation": {
"max": 5
},
"children": [
{
"name": "itemName",
"meta": {
"displayType": "text",
"displayName": "Item Name",
"validation": {
"required": true
}
}
},
{
"name": "items",
"meta": {
"displayType": "object",
"displayName": "Items",
"htmlProps": {
"allowDynamic": true,
"allowAdd": true
},
"validation": {
"max": 5
},
"children": [
{
"name": "itemName",
"meta": {
"displayType": "text",
"displayName": "Item Name",
"validation": {
"required": true
}
}
},
{
"name": "itemQuantity",
"meta": {
"displayType": "number",
"displayName": "Item Quantity",
"validation": {
"required": true,
"min": 1
}
}
}
]
}
},
{
"name": "itemQuantity",
"meta": {
"displayType": "number",
"displayName": "Item Quantity",
"validation": {
"required": true,
"min": 1
}
}
}
]
}
}

Object Configuration Screenshot

This schema and example component outline the use of an Object component with nested structures, supporting dynamic item addition and validation handling.