Not sure how to use Placeholder vs Default Value pre-fill from State #13713
-
Hello , i'm a bit of a bind. In this form, If i don't set the default value and only the placeholder with the data from the state, the page works normally, and the form appears to be pre-filled, however, if i pull the data from the fields of the form and execute a query with them, the fields i haven't changed and are still the placeholders will be sent as null (or 2:00:00 for the datetime) if i do change the default value , then , the page also appears to be working normally, and the query pulls from the fields correctly, but the timepicker becomes almost unusable, because it always add +1 to the hour that i input in, if i change the value whatsoever (minute or hour), an issue that is otherwise not present. what's more it appears that the datetime is actually sent with one more hour than what is displayed , after checking the database after the query I don't know where to go from there or if there is another way to do what I'm trying to do .. Thank you in advance. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Your video doesn't seem to load, but I've got some suggestions that might help. When you run your query from elsewhere in your app, set the value in state Documentation about State here Then for debugging purposes, create a paragraph in your app that contains what you're setting the placeholder value to be. You may find that you're not quite getting back what you expect and prop-drilling isn't working. If that's the case, cut off the last piece of the variable And keep working back until you get something you recognise. Once you've found the right variables and properly indexed them, you should check to see if there's a value there when you set the placeholder text. If you try to return the value of a key that doesn't exist, Budibase will throw an error. Consider using Optional Chaining to avoid getting these errors. You can learn more about it here: MDN Optional Chaining. I hope this helps get you unstuck - if you haven't already, consider joining the Budibase Discord Server. |
Beta Was this translation helpful? Give feedback.
Hi @assia-zoubir
Your video doesn't seem to load, but I've got some suggestions that might help.
When you run your query from elsewhere in your app, set the value in state Documentation about State here
Then for debugging purposes, create a paragraph in your app that contains what you're setting the placeholder value to be. You may find that you're not quite getting back what you expect and prop-drilling isn't working. If that's the case, cut off the last piece of the variable
eg:
JSON.parse($(State.current_task)).data[0].start_time
will becomeJSON.parse($(State.current_task)).data[0
And keep working back until you get something you recognise.
Once you've found the right variables and pr…