Middle
How was the dynamic forms scheme implemented in the promotion builder - on the frontend or received from the backend?
sobes.tech AI
Answer from AI
The dynamic forms scheme in the promotion builder is implemented on the backend and comes to the frontend as a description of the form structure. This allows flexible changes to fields, their types, validation, and logic without the need to modify the frontend code.
For example, the backend returns a JSON describing the fields:
{
"fields": [
{"name": "discount", "type": "number", "label": "Discount", "required": true},
{"name": "startDate", "type": "date", "label": "Start Date", "required": true}
]
}
The frontend renders the form based on this, handles input and validation. This approach simplifies support and extension of the constructor's functionality.