Skip to content

Commit 7003174

Browse files
authored
Merge pull request #310 from FlutterFlow/rewrite/set-form-field-action
Update Form Actions [Set and Reset Form Field Action] + Cursor Position Preserve
2 parents aefd084 + 1ebe064 commit 7003174

8 files changed

+38
-129
lines changed

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

+4-64
Original file line numberDiff line numberDiff line change
@@ -8,73 +8,13 @@ sidebar_position: 1
88
---
99
# Reset Form Field [Action]
1010

11-
This action allows you to reset a value for the Form widgets. This is helpful in clearing out any previously entered data and allows users to start fresh.
11+
The **Reset Form Field** action allows you to reset values in form widgets. This is especially useful for clearing previously entered data and giving users a clean slate.
1212

13-
For example, If a form has been successfully submitted, it may make sense to clear out the form fields so that the user can enter new data if they want to submit the form again.
13+
For example, after a form is successfully submitted, you can use this action to clear the input fields—making it easy for users to enter new information for another submission.
1414

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/8j2HzV0zEQu2JN23K0NG?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>
40-
41-
## Adding Reset 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 **+ Add Action** button. Otherwise, click the "**+**" button below the previous action tile (inside *Action Flow Editor*) and select **Add Action**.
47-
3. Search the **Reset Form Field** (under *State Management*) action and select the widget you would like to reset.
48-
49-
You can reset the same types of widgets in a single action only. e.g., multiple *TextField* widgets.
50-
51-
<div style={{
52-
position: 'relative',
53-
paddingBottom: 'calc(56.67989417989418% + 41px)', // Keeps the aspect ratio and additional padding
54-
height: 0,
55-
width: '100%'}}>
56-
<iframe
57-
src="https://demo.arcade.software/ceKpYitIZcLrq8UKZBdp?embed&show_copy_link=true"
58-
title=""
59-
style={{
60-
position: 'absolute',
61-
top: 0,
62-
left: 0,
63-
width: '100%',
64-
height: '100%',
65-
colorScheme: 'light'
66-
}}
67-
frameborder="0"
68-
loading="lazy"
69-
webkitAllowFullScreen
70-
mozAllowFullScreen
71-
allowFullScreen
72-
allow="clipboard-write">
73-
</iframe>
74-
</div>
75-
<p></p>
15+
![reset-form-field](imgs/reset-form-field.avif)
7616

7717
:::info
7818
You can also reset form fields that are inside the components.
79-
![reset-form-field-component](../../imgs/reset-form-field-component.png)
19+
![reset-form-field-component](imgs/reset-form-field-component.avif)
8020
:::

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

+34-65
Original file line numberDiff line numberDiff line change
@@ -8,73 +8,42 @@ 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 option, it automatically sets the focus on the field once its value is assigned.
32+
33+
This is helpful in scenarios such as an “Edit Full Name” switch—when turned on, the field preloads the existing name and positions the cursor 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), which is useful when the user is already typing and only part of the text has changed.
42+
43+
![focus-field-when-set](imgs/focus-field-when-set.avif)
7544

7645
:::info
77-
You can also set form fields that are inside the components.
46+
You can also set form fields inside the current widget’s child component.
7847
<p></p>
79-
![set-form-field-in-component](../../imgs/set-form-field-in-component.avif)
48+
![set-form-field-component](imgs/set-form-field-component.avif)
8049
:::

0 commit comments

Comments
 (0)