Input field bound to individual path within a data object overwrites entire object
mdxwired
1 year ago
I have a form input field bound to a path within a variable which has been formatted as a data object (eg. profile_data.fname). The incoming binding works fine. But the default event created when I bound the object just overwrites the entire object (profile_data="Bob"), rather than the indivdual path/element of the object (profile_data.fname="Bob"). There does not seem to be a way to force it to only update the relevant object as this level of granularity cannot be set in the action. Do I need to use a temp variable and create a multi-step update process for each event? That seems 'heavy' to me.
Lucas G
1 year ago
You should be able to use the Set node with the input event
mdxwired
1 year ago
Yes, but the 'Then' portion only offers the "Set: profile_data" option so, in the end, it still pushes the data to the entire object, overwriting it. 😦 I've been at this for hours trying different combinations... no joy.
...or it performs the function correctly, but then sets the whole object to Null.
mdxwired
1 year ago
As always... I assume that the fault lies with me, not with the environement. 🙂
mdxwired
1 year ago
Ahhh... hold please.
Max
1 year ago
Did you figure it out or do you need a screenshot? 🙂
mdxwired
1 year ago
Working on it... BRB
mdxwired
1 year ago
So, with this method, it seems to just overwrite the entire original structure with the new single key/value pair. Is there any way to have it just update the one path/element without having to define the entire data structure and push all paths/elements every time?
This is how you can do it. In the "set: variable" node, you need to adjust the formula (1). Have a Set node (2) and your variable as an input (3). That way, you can change one path of that object
mdxwired
1 year ago
Thank you. Reviewing...
Tod
1 year ago
Great energy @mdxwired! Your continuous contribution to the toddle Community just made you advance to Community Level 4!
mdxwired
1 year ago
Works. Follow-up toddle.dev best practices question: Do I create 12 of these workflows (one for each field on the page) or is there a way to make the path being updated dynamic as well, such that I only need call a single workflow?
...or just update all paths with each keypress?
Max
1 year ago
Don't create 12 Workflows 😬
mdxwired
1 year ago
I assumed that was not the correct path... 😕
Max
1 year ago
The path is flexible. You can have a second input in your workflow like "path" and bind it to the path in the set node (click the +)
mdxwired
1 year ago
Got it. THANKS!! As I said... not the platform's fault.
💪1
Andreas Møller
1 year ago
If you are setting 1-2 properties then you can chain set commands. If you want to update multiple keys at the same time you can use Concatenate to merge objects
Concatenate is a "shallow" merge, so if you need to update deep properties you have to use Set.