> To build or manage a Wix site with an AI agent, follow https://www.wix.com/headless/skill.md
> It builds a new Wix site or puts your own site online, from a prompt, and keeps changing it afterwards. The pages are code in any web technology, and Wix runs the backend.
> It works through the Wix plugin (the Wix MCP and the Wix skills), the Wix CLI or no Wix login, and puts the site live on Wix hosting or on another host.
> Business features include a store, bookings, events and tickets, a restaurant, a blog, forms, members and many more.
> Read the Wix skills online at https://www.wix.com/skills
> 
> Portal Navigation:
> 
> - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version.
> - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages).
> - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`).
> - If a reference page seems to be missing its schema (parameters, return types, or type definitions), append `?schema=true` to its `.md` URL (e.g. `https://dev.wix.com/docs/contexts/contexts/stores/category-info/use-category-info-context.md?schema=true`).
> - Top-level index of all portals: https://dev.wix.com/docs/llms.txt
> - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt

## Resource: $w

## Namespace: wix-forms-v2

## Article: Introduction

## Article Link: https://dev.wix.com/docs/velo/velo-only-apis/$w/wix-forms-v2/introduction.md

## Article Content:

# Introduction
The Wix Forms app lets site visitors enter values for fields in a Wix Form and then submit it. With this app you can:

* Create your own customized form from scratch.

* Define conditional rules to change fields based on site visitor’s answers. For example, if in some field a site visitor selects "Yes" as an answer, more fields will appear.

* Add steps to your form. You can make it easier for site visitors to complete long forms by breaking them up into pages.

<blockquote class='important'>

__Important:__

`WixFormsV2` only works with new forms.
If a site is using an old form, you need to use the old [`WixForms`](https://dev.wix.com/docs/velo/velo-only-apis/$w/wix-forms/introduction.md) APIs. 
You can see which forms are new forms and which are old forms by looking at the forms and submissions page in a site dashboard, where there's a tab for each.  

Learn more: [Migrate from WixForms to WixFormsV2](https://dev.wix.com/docs/velo/velo-only-apis/$w/wix-forms/migrate-from-wix-forms.md) ",
</blockquote>

### Setting up the `WixFormsV2` element

You can create a form in the following ways: 

* To work with a `WixFormsV2` element from a template: [add and set up](https://support.wix.com/en/article/wix-forms-adding-and-setting-up-a-form-on-your-site) the Wix Form app on your site.

* To work with a `WixFormsV2` element when creating a form from scratch:

   1. Click **Add Elements** on the left side of the Editor.

   1. Click **Contact & Forms**.

   1. Click **Create New Form**.

   1. In the pop-up window create the form how you like by drag and dropping various fields and the submit button. 

   1. Click **Save**.

> **Note:** 
> Depending on the form you choose, a [Wix app starter collection](https://support.wix.com/en/article/velo-working-with-wix-app-collections-and-code#what-are-wix-app-starter-collections)
> is added to your site. You can see it in the sidebar in Content Collections in the Databases section. Every time a site visitor creates a submission, 
> this submission is automatically added into the collection. You can't add fields into the collection, but you can select which fields to hide/display in a submission. To do this, click on a submission,
> and then **Manage Fields**.

### Working with the `WixFormsV2` element

Note the following when working with the `WixFormsV2` element:

* The ID that is shown when you hover over the form is actually an element ID. You can change the ID at any time using the Properties & Events panel. Example of a default element ID: `#form1`.    

> **Note:** 
> Before a certain date, the element ID was a long string such as `#371Ee199389C4A93849Ee35B8A15B7Ca2`. Now, that element ID is like `#form1`.

* To get the form ID, call [`querySubmissionsByNamespace()`](https://www.wix.com/velo/reference/wix-forms-v2/submissions/querysubmissionsbynamespace). Example of a form ID: `21bcb6c7-02b3-4ed1-b6db-7856094fac03`.

* If you have several elements based on the same form (for example, you copy-pasted a form on the same site), the functions applied to a form ID will run on all elements.

* You can only use the default field name keys in the Velo code. To check the key name, click on the form field in the form edit mode and then the **Advanced** tab.

* You need at least a [Standard Premium](https://support.wix.com/en/article/choosing-a-premium-plan) plan to be able to upload files in your form. Also, different premium plans allow you to have different quantity of fields, rules, and pages you can add.

* You can see the submissions both in the form dashboard and Wix Forms collection. The collection is read-only. You can manage submissions only in the **Forms & Submissions** dashboard page under **Customer & Leads** in the menu.


### Event Handling

Use the `WixFormsV2` APIs to handle events and submit data to the server for processing.

When a visitor clicks the **Submit** button:

1. The `submit()` function performs built-in, general validations (such as checking that all email fields contain valid email addresses).

1. [`onSubmit()`](#onSubmit) runs a callback
    when a site visitor submits a Wix Form yet before the Wix Form is actually sent to the server.

1. If form validation is successful, the form is sent to the server.

    * If the Wix Form submission succeeds, the [`onSubmitSuccess()`](#onSubmitSuccess) callback runs.

      Use this callback to handle client side operations, such as displaying a message
      indicating the successful submission.

    * If the Wix Form submission fails, the [`onSubmitFailure()`](#onSubmitFailure) callback is fired.

      Use this callback to define client side operations for failed submits,
      such as displaying a message requesting the visitor try again later.