# Dynamic forms with slicemachine

**URL:** <https://community.prismic.io/t/dynamic-forms-with-slicemachine/8642>\
**Category:** Developing with Prismic\
**Tags:** slice-machine\
**Created:** [January 13, 2022, 11:48am UTC](https://community.prismic.io/t/dynamic-forms-with-slicemachine/8642 "2022-01-13T11:48:28Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![myrob](https://avatars.discourse-cdn.com/v4/letter/m/f17d59/32.png) [@myrob](https://community.prismic.io/u/myrob)\
**Post date:** [January 13, 2022, 11:48am UTC](https://community.prismic.io/t/dynamic-forms-with-slicemachine/8642/1 "2022-01-13T11:48:28Z")

</div>

Hi everyone,  
I'm currently looking to create a dynamic form with conditional dropdowns.

Here is the scenario:  
I have a dropdown with a `name="contact_reason"` with 4 options,  
When I select an option a new dropdown is displayed with new options (we can call the suboptions).  
Finally I want to submit the key `contact_reason` with the selected `suboption` value

I'm trying to find the best way to handle that through the slicemachine but can't figure out how I can connect different slices together.  
I was also thinking of creating repeatable zone nested in repeteable zone but it doesn't seems allowed.

Any clues to help me? 🙂  
Thanks

---

<div class="post-metadata">

**Author:** ![Priyanka](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/priyanka/32/3223_2.png) [@Priyanka](https://community.prismic.io/u/Priyanka)\
**Post date:** [January 13, 2022, 1:46pm UTC](https://community.prismic.io/t/dynamic-forms-with-slicemachine/8642/3 "2022-01-13T13:46:44Z")

</div>

Hello Romain,

Welcome to the Prismic community, and thank you for reaching out to us.

You can create a dropdown or connect to a different Slices with the help of [Content Relationship field](https://prismic.io/docs/core-concepts/link-content-relationship) in Slice Machine also.

When you create a Slice, give a CR field, and to model this field, click on the pencil button.

 ![Screen Shot 2022-01-13 at 14.40.52](https://europe1.discourse-cdn.com/flex013/uploads/prismic/original/2X/8/830d383c69b06c454d361fd82d3c5518336ffdbc.png)

It will open a layout to choose a different Custom Type to link with this field. You can not link to a specific Slice but a full Custom type.

After that, to retrieve content from Slices, you need to use [GraphQuery](https://prismic.io/docs/technologies/graphquery-rest-api).

**Note** : **GraphQuery only retrieves fields till three levels down.**

Let me know if you have any further questions.

Thanks,  
Priyanka

---

<div class="post-metadata">

**Author:** ![myrob](https://avatars.discourse-cdn.com/v4/letter/m/f17d59/32.png) [@myrob](https://community.prismic.io/u/myrob)\
**Post date:** [January 17, 2022, 9:32am UTC](https://community.prismic.io/t/dynamic-forms-with-slicemachine/8642/5 "2022-01-17T09:32:22Z")

</div>

Thanks Priyanka, CR seems pretty interesting indeed.

I think I cracked it but my graphQuery fails so I fetch the whole customType. Just need to improve that point.

---

<div class="post-metadata">

**Author:** ![Priyanka](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/priyanka/32/3223_2.png) [@Priyanka](https://community.prismic.io/u/Priyanka)\
**Post date:** [January 17, 2022, 12:41pm UTC](https://community.prismic.io/t/dynamic-forms-with-slicemachine/8642/6 "2022-01-17T12:41:08Z")

</div>

Hello @myrob

You need to mention Custom Type API ID while fetching the linked documents. To help you further, I need the following:

1. Configuration of Custom Types and Content relationship field.
2. How are you retrieving fields using Content Relationships? (You can paste your code here).

Thanks,  
Priyanka

---

<div class="post-metadata">

**Author:** ![kris](https://avatars.discourse-cdn.com/v4/letter/k/82dd89/32.png) [@kris](https://community.prismic.io/u/kris)\
**Post date:** [January 17, 2022, 12:43pm UTC](https://community.prismic.io/t/dynamic-forms-with-slicemachine/8642/7 "2022-01-17T12:43:54Z")

</div>

Worth pointing out that fetching Slice Machine slices with graphquery is currently broken.

> [@Not able to query slice-machine slices with graphQuery](https://community.prismic.io/t/not-able-to-query-slice-machine-slices-with-graphquery/7030/13):
>
> I just spent 1 hour trying to figure out this issue before I came across this ticket. Are there any updates on this?

---

<div class="post-metadata">

**Author:** ![Priyanka](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/priyanka/32/3223_2.png) [@Priyanka](https://community.prismic.io/u/Priyanka)\
**Post date:** [January 17, 2022, 2:31pm UTC](https://community.prismic.io/t/dynamic-forms-with-slicemachine/8642/8 "2022-01-17T14:31:38Z")

</div>

Hello @kris

GraphQuery works well with Slice Machine now. What issue are you getting?

Thanks,  
Priyanka

---

<div class="post-metadata">

**Author:** ![kris](https://avatars.discourse-cdn.com/v4/letter/k/82dd89/32.png) [@kris](https://community.prismic.io/u/kris)\
**Post date:** [January 17, 2022, 2:49pm UTC](https://community.prismic.io/t/dynamic-forms-with-slicemachine/8642/9 "2022-01-17T14:49:57Z")

</div>

Hi Priyanka,

The issue has been well explained in the ticket I shared in my other comment.

A colleague of yours said that they were able to replicate it, but there wasn't a follow up comment to say that it was fixed. I just encountered it yesterday.

Cheers,  
Kris

---

<div class="post-metadata">

**Author:** ![myrob](https://avatars.discourse-cdn.com/v4/letter/m/f17d59/32.png) [@myrob](https://community.prismic.io/u/myrob)\
**Post date:** [January 19, 2022, 3:46pm UTC](https://community.prismic.io/t/dynamic-forms-with-slicemachine/8642/10 "2022-01-19T15:46:21Z")

</div>

Hello @Priyanka  
Well I did like this. It works like this without the graphQuery but I fetch to many info

```auto
options.map((option) => {
  return client
         .getByUID(option.subOptions.type, option.subOptions.uid)
         .then((data) => data)
         .catch((err) => console.error(err))
})

```

The CT I use to get the slice I need is

```auto
{
  "id": "dropdown-suboption",
  "label": "Dropdown Suboption",
  "repeatable": true,
  "status": true,
  "json": {
    "Main": {
      "uid": {
        "config": {
          "label": "uid",
          "placeholder": ""
        },
        "type": "UID"
      },
      "slices": {
        "type": "Slices",
        "fieldset": "Slice Zone",
        "config": {
          "choices": {
            "form_input": {
              "type": "SharedSlice"
            }
          }
        }
      }
    }
  }
}

```

Also what I tried is that I called a `<SliceZone>` inside my slice, is it a risky move or not?

---

<div class="post-metadata">

**Author:** ![Priyanka](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/priyanka/32/3223_2.png) [@Priyanka](https://community.prismic.io/u/Priyanka)\
**Post date:** [January 24, 2022, 1:22pm UTC](https://community.prismic.io/t/dynamic-forms-with-slicemachine/8642/11 "2022-01-24T13:22:51Z")

</div>

Hello @myrob

Sorry for not being able to come back on time.

> [@myrob](#):
>
> Well I did like this. It works like this without the graphQuery but I fetch to many info
> 
> ```auto
> 
> ```

Okay. That's a good option too. In that case, you have to fetch many things.

> [@myrob](#):
>
> Also what I tried is that I called a `<SliceZone>` inside my slice, is it a risky move or not?

I don't understand that part. What framework are you using? Can you paste your code here?

Thanks,  
Priyanka
