Skip to content

Commit 7a9da16

Browse files
committed
Rewrite Set Form Field
1 parent f1cc2d2 commit 7a9da16

File tree

4 files changed

+32
-63
lines changed

4 files changed

+32
-63
lines changed

docs/resources/control-flow/user-interactivity/forms/form-actions/set-form-field.md

Lines changed: 32 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -8,70 +8,39 @@ sidebar_position: 0
88
---
99
# Set Form Field [Action]
1010

11-
This action allows you to set a value for the Form widgets. For example, you could use this action to auto-populate a form based on a user's previous submission.
12-
13-
You could also dynamically update a dropdown menu based on a user's previous selection, such as showing relevant cities based on a selected country.
14-
15-
<div style={{
16-
position: 'relative',
17-
paddingBottom: 'calc(56.67989417989418% + 41px)', // Keeps the aspect ratio and additional padding
18-
height: 0,
19-
width: '100%'}}>
20-
<iframe
21-
src="https://demo.arcade.software/7YwkCFeBsQ6rnYzr3zQh?embed&show_copy_link=true"
22-
title=""
23-
style={{
24-
position: 'absolute',
25-
top: 0,
26-
left: 0,
27-
width: '100%',
28-
height: '100%',
29-
colorScheme: 'light'
30-
}}
31-
frameborder="0"
32-
loading="lazy"
33-
webkitAllowFullScreen
34-
mozAllowFullScreen
35-
allowFullScreen
36-
allow="clipboard-write">
37-
</iframe>
38-
</div>
39-
<p></p>
11+
The **Set Form Field** action allows you to programmatically populate or update the value of any input widget—like a TextField, Dropdown, or other form elements—at runtime. This is especially useful when you want to quickly fill or modify user input fields based on user preferences (e.g., saved addresses) or pre-stored information.
4012

41-
## Adding Set Form Field action
42-
43-
Follow the steps below to add this action to any widget.
44-
45-
1. Select the **Widget** (e.g., Button, etc.) on which you want to add the action.
46-
2. Select **Actions** from the properties panel. If it's the first action, click the **+ Add Action** button. Otherwise, click the "**+**" button below the previous action tile (inside *Action Flow Editor*) and select **Add Action**.
47-
3. Search the **Set Form Field** (under *State Management*) action and select the widget you would like to set.
48-
4. Now, you can set its value directly or from a variable.
49-
50-
<div style={{
51-
position: 'relative',
52-
paddingBottom: 'calc(56.67989417989418% + 41px)', // Keeps the aspect ratio and additional padding
53-
height: 0,
54-
width: '100%'}}>
55-
<iframe
56-
src="https://demo.arcade.software/dnZobgoW5fi0Jm4OkFvL?embed&show_copy_link=true"
57-
title=""
58-
style={{
59-
position: 'absolute',
60-
top: 0,
61-
left: 0,
62-
width: '100%',
63-
height: '100%',
64-
colorScheme: 'light'
65-
}}
66-
frameborder="0"
67-
loading="lazy"
68-
webkitAllowFullScreen
69-
mozAllowFullScreen
70-
allowFullScreen
71-
allow="clipboard-write">
72-
</iframe>
73-
</div>
74-
<p></p>
13+
:::info[possible use cases]
14+
15+
- **Use Saved Address:** If a user toggles "Use Saved Address," you might set the Full Name, Street Address, City, and ZIP Code fields to values pulled from a user profile or database.
16+
- **Edit Existing Data:** When navigating to an "Edit Profile" page, you can auto-populate the TextFields with the current user info so they only change what’s needed.
17+
- **Auto select Country/State Dropdown:** Automatically select the user's country and state based on location services or their account settings.
18+
19+
:::
20+
21+
While adding the Set Form Field action, select the target widget (e.g., `TextField`) and assign a value—this could come from a variable like `fullName` in your backend, app state, or page parameters.
22+
23+
![set-form-field-action.avif](imgs/set-form-field-action.avif)
24+
25+
If you need to update several widgets (such as a TextField and a Dropdown), use a separate Set Form Field action for each and specify the appropriate value.
26+
27+
![multiple-set-form-field.avif](imgs/multiple-set-form-field.avif)
28+
29+
#### Focus Field When Set
30+
31+
You can also set additional preferences like whether the field should be focused and how the cursor should behave using the **Focus Field When Set** option. When you enable the Focus Field When Set option, it automatically sets the focus on the field once its value is assigned.
32+
33+
It is helpful in a scenario like an “Edit Full Name” switch—when turned on, the field preloads the existing name and puts the cursor in place for immediate editing.
34+
35+
36+
When Focus Field When Set is enabled, you can set one of the following **Cursor Position**:
37+
38+
- **End**: Places the cursor at the end of the newly filled text, letting the user continue typing from the last character.
39+
- **Start**: Positions the cursor at the beginning of the text.
40+
- **Highlight**: Selects (highlights) the entire text, letting the user immediately overwrite it.
41+
- **Preserve**: Maintains the cursor location as it was, if any—useful if the user was already typing and you only partially changed the text.
42+
43+
![focus-field-when-set](imgs/focus-field-when-set.avif)
7544

7645
:::info
7746
You can also set form fields that are inside the components.

0 commit comments

Comments
 (0)