# Form with multiple fields generated using JSON

**URL:** <https://community.n8n.io/t/form-with-multiple-fields-generated-using-json/297753>\
**Category:** Help me Build my Workflow\
**Tags:** node\
**Created:** [June 1, 2026, 9:12pm UTC](https://community.n8n.io/t/form-with-multiple-fields-generated-using-json/297753 "2026-06-01T21:12:45Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michal\_Moraszczyk](https://avatars.discourse-cdn.com/v4/letter/m/ce7236/32.png) [@Michal\_Moraszczyk](https://community.n8n.io/u/Michal_Moraszczyk)\
**Post date:** [June 1, 2026, 9:12pm UTC](https://community.n8n.io/t/form-with-multiple-fields-generated-using-json/297753/1 "2026-06-01T21:12:45Z")

</div>

Hi,

I have a workflow, where I want to build a dropdown with some dates based on the submission of the form trigger node. I also would like to add a condition based on the selected radio button in the form trigger node. I created JSON code node as in the attached file. I have a problem, however, to build the next form properly (“Add dates” node in the attached workflow). I want it to display two fields: the dropdown labelled “form fields” and the text input labelled “NIP”. Unfortunately, either it displays only one field (as in the attached workflow) or, after some modifications, it throws an error “not valid json”. Does anybody have an idea how to build this node to achieve my goal?

---

<div class="post-metadata">

**Author:** ![kjooleng](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/kjooleng/32/184045_2.png) [@kjooleng](https://community.n8n.io/u/kjooleng)\
**Post date:** [June 2, 2026, 5:15am UTC](https://community.n8n.io/t/form-with-multiple-fields-generated-using-json/297753/2 "2026-06-02T05:15:00Z")

</div>

Hi @Michal_Moraszczyk

Can you try this?

---

<div class="post-metadata">

**Author:** ![BESTOFRENTO](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/bestofrento/32/175166_2.png) [@BESTOFRENTO](https://community.n8n.io/u/BESTOFRENTO)\
**Post date:** [June 2, 2026, 10:01am UTC](https://community.n8n.io/t/form-with-multiple-fields-generated-using-json/297753/3 "2026-06-02T10:01:35Z")

</div>

Hi Michal,

The issue is likely how your Code node outputs the JSON. The Form node expects a **JSON array** at the top level of the output — not nested inside an object or wrapped in a string.

Here’s a working structure for your “Add dates” Form node (set to “Define form using JSON”):

```json
[
  {
    "fieldLabel": "Select Date",
    "fieldType": "dropdown",
    "fieldOptions": {
      "values": [
        { "option": "your_dynamic_date_1" },
        { "option": "your_dynamic_date_2" }
      ]
    },
    "requiredField": true
  },
  {
    "fieldLabel": "NIP",
    "fieldType": "text",
    "placeholder": "Enter NIP",
    "requiredField": true
  }
]

```

**Common pitfalls that cause “not valid json” or only one field showing:**

1. **Wrapping in an object** — Don’t return `{ "fields": [...] }`. The Form node expects the array directly. Return just the array.

2. **Returning as a string** — If your Code node does `JSON.stringify()`, the Form node receives a string instead of a parsed object. Return the array as an actual object.

3. **Multiple items instead of one** — Your Code node should return **one item** containing the full array. Use this pattern in your Code node:

```javascript
const fields = [
  {
    fieldLabel: "Select Date",
    fieldType: "dropdown",
    fieldOptions: {
      values: dates.map(d => ({ option: d }))
    },
    requiredField: true
  },
  {
    fieldLabel: "NIP",
    fieldType: "text",
    placeholder: "Enter NIP",
    requiredField: true
  }
];

return [{ json: fields }];

```

The `return [{ json: fields }]` is the key part — single item, array goes into `json`. This is what most people miss.

For the radio button condition — use an **IF node** after the Form Trigger to branch, and connect the correct branch to the “Add dates” Form node. Each branch can have its own Form node with different field definitions.

Hope this helps!

---

<div class="post-metadata">

**Author:** ![Michal\_Moraszczyk](https://avatars.discourse-cdn.com/v4/letter/m/ce7236/32.png) [@Michal\_Moraszczyk](https://community.n8n.io/u/Michal_Moraszczyk)\
**Post date:** [June 2, 2026, 5:40pm UTC](https://community.n8n.io/t/form-with-multiple-fields-generated-using-json/297753/4 "2026-06-02T17:40:41Z")

</div>

Hi,

Your solution worked for me perfectly. Thank you!

---

<div class="post-metadata">

**Author:** ![Michal\_Moraszczyk](https://avatars.discourse-cdn.com/v4/letter/m/ce7236/32.png) [@Michal\_Moraszczyk](https://community.n8n.io/u/Michal_Moraszczyk)\
**Post date:** [June 2, 2026, 5:44pm UTC](https://community.n8n.io/t/form-with-multiple-fields-generated-using-json/297753/5 "2026-06-02T17:44:30Z")

</div>

Hi,

Your explanation is thorough and valuable. I will bear your recommendation in mind - they will be helpful also in my future workflows. Thank you!
