# Contact Form

## Customizing the Contact Form

**Files:** `src/content/sections/<language>/contact-section.md`, `src/config/config.toml` · **Skill level:** Beginner

Upstart comes with a built-in contact form that supports popular form handling providers like [Formspree](https://formspree.io/), [FormSubmit](https://formsubmit.co/), and [Netlify Forms](https://docs.netlify.com/forms/setup/).

You can easily customize the form fields or change the submission email address without writing JavaScript or server-side code.

In the Tina edition, the fields are under **Section defaults**, `contact-section`, at `/admin/`. In the Sanity edition, they are under **Sections**, **Contact section**, **Form**, in the Studio. In both, the provider settings are under **Site settings > Settings**.

---

### How to Add a New Form Input

To modify the fields shown in the contact form (like adding a new input), follow the steps below:

#### Step 1: Locate the Contact Form Markdown File

The contact form fields are controlled by a Markdown file located at:

```md
src/content/sections/<language>/contact-section.md
```

#### Step 2: Edit the Form Fields in Markdown Frontmatter

Here’s a shortened view of the frontmatter. Edit the same file in each language folder.

```yaml
---
enable: true
title: "Contact Us for More **Information**"
description: "Whether you're seeking expert assistance, our dedicated team is prepared to support you every step of the way."
subtitle: "Contact"

# Check config.toml file for form action related settings
form:
  emailSubject: "New form submission from upstart website"
  submitButton:
    label: "Submit"
  inputs:
    - label: ""
      placeholder: "Full Name"
      name: "Full Name" # This indicates under which name you receive this field's data
      required: true
      halfWidth: true
      defaultValue: ""
    - label: ""
      placeholder: "Email Address"
      name: "Email Address"
      required: true
      type: "email"
      halfWidth: true
      defaultValue: ""
    - label: ""
      tag: "textarea"
      defaultValue: ""
      rows: "4"
      placeholder: "Enter your message."
      name: "Message"
      required: true
      halfWidth: false
---
```

The file also holds `contactList`, the sample phone, email, and chat details shown beside the form, and `social`. Replace the sample details with your own. The phone, email, and address listed in `llms.txt` are separate: they are `[settings.contactInfo]` in `config.toml`.

#### Step 3: Add a New Input Field

To add a new input field (e.g., for a phone number), add another object under `form.inputs`. Here's how you can add a `tel` input:

```yaml
- label: ""
  placeholder: "Phone Number"
  name: "Phone Number"
  required: false
  type: "tel"
  halfWidth: true
```

> You can use any standard input `type`: `text`, `email`, `tel`, `url`, etc. For a larger text box, use `tag: "textarea"`. The sample form also shows a `dropdown` list and `type: "radio"` inputs that you can copy.

---

### Changing the Email for Form Submissions

To change where form submissions are sent, update the `config.toml` file:

#### Step 1: Open `src/config/config.toml`

Look for the following settings:

```toml
# Form action URL for the contact form
[settings]
  contactFormAction = "https://formsubmit.co/your_form_submission_receive_email"
  contactFormProvider = "formsubmit.co" # formsubmit.co | formspree | netlify
```

#### Step 2: Update the Email in the Form Action URL

Change the `contactFormAction` to match the provider you're using:

##### ▶ For FormSubmit (default)

Update the email in the URL:

```toml
[settings]
  contactFormAction = "https://formsubmit.co/your_email@example.com"
  contactFormProvider = "formsubmit.co"
```

##### ▶ For Formspree

Use your Formspree endpoint (you'll get this after creating a form):

```toml
[settings]
  contactFormAction = "https://formspree.io/f/yourformid"
  contactFormProvider = "formspree"
```

##### ▶ For Netlify

If you’re deploying to Netlify and want to use Netlify Forms:

```toml
[settings]
  contactFormAction = "/"
  contactFormProvider = "netlify"
```

Make sure your site is deployed to Netlify. The theme adds the `data-netlify` attribute to the `<form>` element for you when the provider is `netlify`.

---

#### Bonus Tips

- All input types respect HTML5 validation based on the `required` and `type` values.
- The `label`, `name`, and `placeholder` fields are fully customizable.

<Aside type="tip">
  If you're using Formspree or FormSubmit, don't forget to `verify the email` on
  their platform to start receiving submissions.
</Aside>