I want to do a very simple thing, but can’t seem to find out how…
I want to change an inputs value based on an action (workflow).
In this specific case I’ve got an address input. I want to use a button to let the user choose/fill an already stored address (from an organizer ‘thing’) instead of typing it anew. So set input value to organizer’s address.
The only way I find googling is to use states. But I can’t set the default state dynamically. Messing things up if I want to change an already existing item. In that cause the default input value is the already stored value…
How should I go about this? Seems simple enough, so I feel I’m missing something.
Hi there, @steven11… if I understand your post correctly, a custom state would do the trick here. Doing what you described could be as simple as setting a custom state to a particular value when the button is clicked, and you would have a condition on the address input that says when the custom state is the particular value, the initial content of the input is the organizer’s address.
The above being said, I have to admit I didn’t really follow this part of your post.
I’m guessing I am missing something in there that makes the custom state idea a no-go for you, but I don’t really know what it is that I am missing. If you can elaborate or share some screenshots of your setup, it might be easier to help.
Thanks for helping out.
I’ll try to make it more clear.
I use the same page/form to create & edit a thing (listing).
One form input is for ‘address’
If it is a new listing this can be empty (no default value)
If it is an existing listing the default value should be the stored value
I want to add a button to set the address input field to the (existing) organizer’s (other thing) address (stored value).
If I use a state for this (to refer to as the default value for the address input field) I can update this state using a workflow. But I can’t set a dynamic default for the state. Which in this case should be the address of the existing listing - if there is one.
The only way I can think of now is to create a workflow that triggers ‘on pageload’. To set the properp ‘default value’ of this state. But this all seems like a very roundabout way to achieve something really simple: changing the value of an input field. So still feel like I’m missing something…
If you are using the same form to create and edit a listing, you must have a way for the form to differentiate between the two actions (create vs. edit), right? For example, all of the form’s inputs could be in a group, and the group could have a custom state to hold an existing listing. If the custom state is empty, the form is being used to create a new listing. If it’s not empty, the form is being used to edit an existing listing.
The above being said, you could have a conditional on the address input to display an existing listing’s address as the input’s initial content when the custom state that holds an existing listing is not empty. Then, you could set a different custom state to pretty much any value (maybe it’s a yes/no and you set it to yes) when a button is clicked, and you could use the value of that custom state as part of another conditional on the address input to change the input’s initial content to a different address when the value of the custom state is yes.