Save values on page reload #15773
-
Tell me please how can I implement saving values when reloading the page in the input fields? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hey @bartlebi - I'm sorry to hear you're having this issue. Let's get stuck in - Firstly, we can check if there's a bug with state values persisting with a simple screen - I've got a text field, a button that sets the state using the value from the field, and a headline component to display the state. For the On-Click actions of the button, we take the value of New Text Field and save it to the key of 'value', making sure to check the "Persist this value" option. When we publish the app, I can then add a value, save it to state, and see it reflected in the headline component. Refreshing the page will maintain the text saved in the state. Demonstrated here: https://jam.dev/c/3821fb19-b3d5-41eb-b317-0eb4ed5dcbe5 We can then make sure that the value saved in state is applied the default value of the form field, should the page get refreshed. Demonstrated here: https://jam.dev/c/ae60312b-ddbb-4dca-8931-fb694f6dba31 In order to make sure we save a partially completed form, we need to use an "On Change" action for each field, which sets the field value in state. We should also set the default value accordingly. As part of your "Save" button's action flow, you should also include an "Update State" to clear the state values so as not to confuse the user or result in accidental duplicate submissions. I've tacked mine in at the end of the Form Block's default action-flow for the Save button. Hopefully this helps - if you're still having trouble please let us know and we'll see how we can help further. |
Beta Was this translation helpful? Give feedback.
Hey @bartlebi - I'm sorry to hear you're having this issue. Let's get stuck in -
Firstly, we can check if there's a bug with state values persisting with a simple screen - I've got a text field, a button that sets the state using the value from the field, and a headline component to display the state.
For the On-Click actions of the button, we take the value of New Text Field and save it to the key of 'value', making sure to check the "Persist this value" option.
When we publish the app, I can then add a value, save it to state, and see it reflected in the headline component. Refreshing the page will maintain the text saved in the state.
Demonstrated here: https://jam.dev/c/3821fb19-b3d5…