Form Data ($f)
Access any field’s value anywhere within a form instance.
Summary
↳ Examples
The special $f
variable represents the form data values within Superform. It allows access to any field’s value anywhere in the form, enabling dynamic interaction based on user input.
Access Form Fields: Retrieve the value of any form field by referencing it with
$f.fieldName
.Dynamic Logic: Utilize form field values to create dynamic and conditional navigation or actions.
Real-Time Updates: Automatically updates as users fill out the form, ensuring real-time data access.
Examples
Since Superform is built in vanilla JavaScript, you will see both HTML and Webflow examples, it's practically the same — works with Webflow's Custom Element and elements inside Code Embed.
1. Using with Reactivity attributes (visibility)
Toggle visibility based on age input's data.
HTML Example
Webflow Example
2. Using with Logic / Conditionals
Navigate to different steps based on user input.
HTML Example
Webflow Example
Naming Form Fields Properly
When naming your form fields in Superform, following best practices ensures smoother development and avoids potential issues. Here are the key guidelines:
Start with a Letter, Underscore (_):
Variable names must begin with a letter (a-z, A-Z), an underscore (_).
Example:
name
,_userName
.
No Spaces:
Variable names cannot contain spaces.
Use camelCase or underscore (_) to separate words.
Example:
firstName
,emailAddress
,first_name
.
No Emojis or Symbols:
Variable names should not include emojis or symbols other than underscores (_) or dollar signs ($).
Example: Avoid
name😄
,price$
,quantity%
.
Handling Improperly Named Fields
If you still want to use names that don't follow these conventions, such as fields with spaces or emojis, you can access them using bracket notation.
Example:
Field name:
"123 lol ive space 😄"
Access:
$f['123 lol ive space 😄']
HTML Example
Following these guidelines will help speed up your development process and ensure consistency across your form fields.
Last updated