State field
What it does
A State field asks for a state, province or region. You find it in the builder's left panel, in the Store Data group, and add it by dragging it onto the form, as described in Adding fields and sections.
The field works together with a country:
- Linked to a Country field. The visitor first chooses a country in a Country field. When Magento has a list of states for that country, such as the United States, Canada or Germany, the State field becomes a list of them. For other countries, and while no country is chosen, it's a box the visitor types into.
- One fixed country. The field lists the states of the country you chose, for example the provinces and territories of Canada. Choose a country Magento has a list of states for.
The list starts with "Please select a region, state or province." The state names come from Magento's own list.
The submission page, the Inbox column and emails show the state's name, for example "Oregon".
When to use
- Use State with a Country field when you need the region as a separate answer.
- Use it with one fixed country when all your customers are in one country, for example to ask which province a delivery goes to.
- Use an Address field for a full postal address. It has its own state part.
Settings
Go to Content → WebForms → Manage Forms, click the form's name, then click Form Builder. Click the field on the form. Its settings show in the right panel, on the tabs General and Appearance. You'll change these settings most often:
- Country Field (General tab) picks the Country field on this form that the list follows. Only Country fields of this form are offered.
- Country picks one fixed country instead. When it's set, Country Field is ignored, so set only one of the two.
- Required makes the visitor give a state before the form can be sent.
The table below lists every setting. Visitors see a change after you click Publish Changes in the builder's top bar.
All settings of this field
| Setting | Where in the panel | Values | Translatable |
|---|---|---|---|
| Enable Field | General → Basic | On or off | No |
| Label (required) | General → Basic | Text | Yes |
| Field Code | General → Basic | Text | No |
| Required | General → Basic | On or off | No |
| Required Error Message | General → Basic | Text | Yes |
| Help Text | General → Basic | Formatted text | Yes |
| Tooltip | General → Basic | Formatted text | Yes |
| Country Field | General → Field Settings | A Country field of this form | No |
| Country | General → Field Settings | A list of 249 options | No |
| Hide in Submissions | General → Submission Display | On or off | No |
| Allow in Staff Email Subject | General → Submission Display | On or off | No |
| Submission Label | General → Submission Display | Text | Yes |
| Personal Data | General → Privacy | By field type — Personal data, Not personal, Personal data | No |
| Desktop | Appearance → Layout | Width: Full (1/1), Half (1/2), Third (1/3), Quarter (1/4), Fifth (1/5), Sixth (1/6), 2/3, 3/4, 2/5, 3/5, 4/5, 5/6; New row: on or off | No |
| Tablet | Appearance → Layout | Width: Full (1/1), Half (1/2), Third (1/3), Quarter (1/4), Fifth (1/5), Sixth (1/6), 2/3, 3/4, 2/5, 3/5, 4/5, 5/6; New row: on or off | No |
| Mobile | Appearance → Layout | Width: Full (1/1), Half (1/2), Third (1/3), Quarter (1/4), Fifth (1/5), Sixth (1/6), 2/3, 3/4, 2/5, 3/5, 4/5, 5/6; New row: on or off | No |
| Show Label | Appearance → Style | On or off | No |
| Help Text Position | Appearance → Style | Below input, Above input | No |
| Container Classes | Appearance → CSS | Text | No |
| Input Classes | Appearance → CSS | Text | No |
| Custom Attributes | Appearance → Advanced | Text | No |
| Inline Style | Appearance → Advanced | Text | No |
Country Field in the table lists the Country fields of this form.
Validation
| Check | What the visitor sees |
|---|---|
| Required, while the field is a list | "Please select an option." under the list. |
| Required, while the field is a text box | After Submit, a window titled Error with the field's label and "is required", for example "Billing state is required". |
The field has no Validation tab.
Logic
- Start a rule: no. A State field can't start one. Its Logic tab appears only once a rule shows or hides it, and lists that rule.
- Show or hide this field: yes. Start the rule on another field that has a Logic tab, such as a Select, and choose this field as the one to show or hide. See Show or hide fields and sections.
- Email conditions: the field is listed with Is and Is Not and a box for the value. Type the state's
name, such as
Oregon; letter case doesn't matter. A state picked from the list is compared by its name in Magento's list, for example the German states in German. See Recipients and conditions.
Limits
- The field isn't filled in from a signed-in customer's account, even when the linked Country field is.
- By default, a state counts as personal data. Through the Management API and AI assistants the answer is masked. See Personal data masking.
- State names are shown as Magento stores them, for example the German states in German.
Troubleshooting
- The field stays a text box after the visitor chooses a country. If Country Field is empty, pick the Country field there and publish the form. If it's already set, Magento has no list of states for that country, and the text box is expected.
- The list shows the wrong country's states. Country is set to a fixed country. Clear it to follow the Country field.
What's next
- Country field: the list of countries this field follows.
- Address field: a full postal address in one field.