#Json form related query

1 messages · Page 1 of 1 (latest)

faint grove
#

Hi everyone, i was trying JSON FORM widget in self hosted appsmtih and i wanted to recreate this use case

  1. Wanted to dynamically generate different types of forms.
  2. And these forms have different field types and json for them are stored in DB.

Here i need to set the required property of fields dynamically too, how do i do it? Does appsmith's JSON form widget supports this functionality? If i manually set the required property it will be gone if i change the form and comeback to this.

full shaleBOT
#

Hello! I'm AppBot, your support assistant for Appsmith. Yes, the JSON Form widget in Appsmith supports dynamic configurations, including setting the "required" property of fields dynamically.

To achieve this, you can use the formData property of the JSON Form widget to dynamically set the required fields. Here's a basic example of how you can do it:

  1. Fetch the JSON configuration from your database using a query.
  2. Use the formData property to bind the fetched JSON configuration to the JSON Form widget.

For example, if you have a query named FetchFormConfig that retrieves the form configuration from your database, you can set the formData property of the JSON Form widget like this:

{?{ FetchFormConfig.data }?}

In your JSON configuration, you can specify the "required" property for each field. Here's an example JSON structure:

json
{
"schema": {
"type": "object",
"properties": {
"name": {
"type": "string",
"title": "Name"
},
"age": {
"type": "number",
"title": "Age"
}
},
"required": ["name"] // Dynamically set required fields
}
}

Make sure your JSON structure includes the "required" array, which lists the fields that should be required. You can dynamically modify this array based on your application's logic before binding it to the JSON Form widget.

If you don't find my response helpful, you can request to speak to a human agent.

faint grove
#

This is just creating one more field called required, it would be great if i can speak to human agent

full shaleBOT
#

Someone from our team will reach out to you on this thread. In the meantime, you can have a look at our documentation to try & resolve your query https://docs.appsmith.com?utm=bot

Organizations build internal applications such as dashboards, database GUIs, admin panels, approval apps, customer support tools, etc. to help improve their business operations. Appsmith is an open-source developer tool that enables the rapid development of these applications. You can drag and drop pre-built widgets to build UI. Connect securely...

full shaleBOT
#

Hello! I'm Amelia with Appsmith Support. The form layout updates automatically when the field types inside the Source Data are changed if you enable the Auto Generate Form property. This means that any manual configuration you did to the fields is lost once it gets regenerated. It also overrides any custom configurations that you are providing through data transformations using JavaScript.
If you disable this setting, then the Generate Form button becomes visible and you can manually regenerate the form layout. With this, the Field Configuration property also gets updated to reflect any changes in the Source Data property.

This page provides information on how to use the JSON form widget, which efficiently generates forms from JSON data, eliminating the need for manual form creation.

faint grove
#

Oh okok got it, thanks 🙌