Webflow Forms enable users to capture and collect information from visitors on a site. Forms are essential for gathering user data, feedback, and enabling key interactions.

Form structure

A Webflow form consists of several nested elements that work together:

ElementDescription
FormWrapperThe outermost container element that encapsulates the entire form structure
FormFormThe main form element containing all form fields and inputs (nested in FormWrapper)
FormSuccessMessageDisplays a success message after successful form submission (nested in FormWrapper)
FormErrorMessageShows error messages if form submission fails (nested in FormWrapper)

The methods documented below apply specifically to the FormForm and FormWrapper elements. For more information about creating and styling forms, see the Forms lesson in Webflow University.

Properties

PropertyDescriptionTypeExample
idThe unique identifier for the form.object{component: "64c813...", element: "5edf8e59-71f9..."}
typeThe type of the element.string"FormForm" || "FormWrapper
childrenIndicates if the element can contain child elements.booleantrue
customAttributesIndicates if the element can contain custom attributes.booleantrue
stylesIndicates if the element can contain styles.booleantrue
textContentIndicates if the element can contain text content.booleanfalse
appConnectionsIndicates if the element can contain app connections.booleantrue

Methods

The methods documented below apply specifically to the FormForm and FormWrapper elements.

form.getName()

Retrieves the name of the form.

Syntax

1form.getName(): Promise<string>

Returns

Promise<name>: String - The name of the form.

Example

1const selectedElement = await webflow.getSelectedElement()
2
3if (selectedElement?.type === 'FormForm' || selectedElement?.type === 'FormWrapper'){
4
5 const name = await selectedElement.getName()
6 console.log(name)
7
8} else {
9 console.log("Selected Element is not a Form Element")
10}

form.setName(name: string)

Sets the name of the form.

Syntax

1form.setName(name: string): Promise<null>

Parameters

  • name: String - The name of the form.

Returns

Promise<null>

A Promise that resolves to null.

Example

1const selectedElement = await webflow.getSelectedElement()
2
3if (selectedElement?.type === 'FormForm' || selectedElement?.type === 'FormWrapper'){
4
5 await selectedElement.setName("My Form")
6
7} else {
8 console.log("Selected Element is not a Form Element")
9}
Built with