Conditional field depending on another radio field selection

Hi,

I am trying to build a form with conditional fields that depend on a radio selection.
In other words, if user selects one radio option, the conditional fields would show up; on the other hand, if the user selects the other radio option, the conditional fields would hide.

This is the markdown file I’ve done so far:

form:
    name: form1
    fields:
        - name: radio_field
          label: Have you ever changed your name?
          type: radio
          options:
              '0': 'No'
              '1': 'Yes'
          validate:
            required: true
        - name-change-condition:
          type: conditional
          condition: "[[CONDITION HERE]] ? 'true' : 'false'"
          fields:
            - name: new-firstname
              type: text
            - name: new-lastname
              type: text

Is this possible using the conditional fields on the form plugin?

Thanks in advance

Conditional field will display a field or not base on a twig condition. This condition is only evaluated on the page load, so if it is a multi-page form (like a poll), it could work, otherwise, you might have to use javascript for this task.

Thanks for your response, Paul.
This is what I thought but I wanted to be sure though.
I will do it with JS then

Hi David, can you share your final solution? I am in need of this too

Hi @parijke,

What do you need exactly?

Hi Paul,

What I need is a form with checkboxes (mortgage, insurance)

Depending on the choice ie mortgage additional form fields need to be shown like Purchase Price and Mortgage Required