Adding a form to Prismic

Hi everyone :slight_smile:

I'm building out my contact page and would like to have a contact form that includes inputs and a couple of dropdowns. historically in react i've done this with yup and formik and so I'm wondering how that would look like with prismic? What is the best route to code a form leveraging Prismic in next13?

Thanks in advance!


Hi @odelia.finkel

For my usage, I end up creating a forms slice (with variations as needed) by usecase.

So let's say I make a Form slice. The default form might be a contact form. The variations would then be other forms perhaps a "schedule an appointment" form or something.

In Prismic/Slicemachine, I would then use fields to allow the content people to control things like labels/placeholder text/ and button text/color. I don't believe you can make a form builder for your content team at this time. You can create slice variants on an as-needed basis.



1 Like

Hey @odelia.finkel ,

Neil's suggestion here is really good; you can also check out this thread about forms:

Hey Phil & Neil,

I ended up creating a form slice for name/email/address etc and using Formik in my code editor. my issue right now is that part of the form should be a dropdown with an options of services that the user would be able to choose from. my problem is that in slice i don't have the option to choose a group field the way i would in a custom type. I'm sort of stuck now because if I use a custom type I'd only be able to put that into a component which would then be an issue to add it only to the form route. any tips to still use a slice and be able to map over service options for a dropdown? hopefully this is clear!

@odelia.finkel ,

In this situation, I end up asking the client what they want in the dropdown. It's probable that these options won't change too frequently. The select options are then coded into the slice.

You are correct that the lack of groups in slices is a limitation many of us have run into. The Prismic die-hards are hoping it will eventually come to be.

It might be possible to make a custom type for select fields like this and then use a content relationship field in your slice. But this feels like an awful "hack"/workaround.