How To Initial Form UI

Hi
How To initialize Form
Example : When Start Program TextInput In Form Value Initial = Hello World.

I assume you are asking how to initialize a form?

This is what I use to pre-fill a drop-down menu.

[{"id":"b5e4059e.5d7a28","type":"inject","z":"4e4657de.9b461","name":"Initial reset","topic":"","payload":"","payloadType":"str","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":190,"y":200,"wires":[["d8ec9a42.ad7708"]]},{"id":"a532c2b5.0e645","type":"ui_dropdown","z":"4e4657de.9b461","name":"Data source","label":"","tooltip":"","place":"","group":"9c66415.50bbe4","order":1,"width":"4","height":"1","passthru":false,"options":[{"label":"","value":"","type":"str"}],"payload":"","topic":"datasource","x":890,"y":200,"wires":[[]]},{"id":"d8ec9a42.ad7708","type":"function","z":"4e4657de.9b461","name":"Set-up name-value map","func":"// This mapping file uses {\"name\":\"value\"} pairs to pre-fill the drop-down widget in the dashboard\n\nmsg.payload = \n[ \n    {\"[Remove all]\":\"delete\"},\n    {\"Lounge temperature\":\"lounge/temperature\"},\n    {\"Snug temperature\":\"snug/temperature\"}, \n    {\"Studio temperature\":\"studio/temperature\"},\n    {\"Study temperature\":\"study/temperature\"},\n    {\"Rear bedroom temperature\":\"rear_bedroom/temperature\"},\n    {\"Rear bedroom humidity\":\"rear_bedroom/humidity\"},\n    {\"Rear bedroom pressure\":\"rear_bedroom/pressure\"},\n    {\"Garage temperature\":\"garage/temperature\"},\n    {\"Loft temperature\":\"loft/temperature\"}\n];\nreturn msg;","outputs":1,"noerr":0,"x":430,"y":200,"wires":[["cb2b51b0.8fd79"]]},{"id":"cb2b51b0.8fd79","type":"change","z":"4e4657de.9b461","name":"","rules":[{"t":"set","p":"options","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":680,"y":200,"wires":[["a532c2b5.0e645"]]},{"id":"52feabff.97a174","type":"comment","z":"4e4657de.9b461","name":"Pre-fill the ui-dropdown widget","info":"","x":550,"y":160,"wires":[]},{"id":"9c66415.50bbe4","type":"ui_group","z":"","name":"Filters","tab":"412738d1.eb7ae","order":2,"disp":true,"width":"24","collapse":false},{"id":"412738d1.eb7ae","type":"ui_tab","z":"","name":"Data capture and charting","icon":"dashboard","order":10}]
1 Like

Just send in the values you want when the flow starts....

[{"id":"77d7ffd4.edef9","type":"inject","z":"ea593186.4918d","name":"init","topic":"","payload":"{\"Temp\":\"Hello World\"}","payloadType":"json","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":130,"y":1340,"wires":[["d44c36e1.67d618"]]},{"id":"d44c36e1.67d618","type":"ui_form","z":"ea593186.4918d","name":"","label":"","group":"5749dfff.2a222","order":7,"width":0,"height":0,"options":[{"label":"Temp","value":"Temp","type":"text","required":true,"rows":null}],"formValue":{"Temp":""},"payload":"","submit":"submit","cancel":"cancel","topic":"","x":290,"y":1340,"wires":[["28bdccda.4fb624"]]},{"id":"28bdccda.4fb624","type":"debug","z":"ea593186.4918d","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":470,"y":1340,"wires":[]},{"id":"5749dfff.2a222","type":"ui_group","z":"","name":"Default","tab":"8d16f8ce.591d18","disp":true,"width":"6","collapse":false},{"id":"8d16f8ce.591d18","type":"ui_tab","z":"","name":"Home","icon":"dashboard","disabled":false,"hidden":false}]
1 Like

I think it will be better to use ui_control node instead of regular inject node for dashboard widget wake up flows. (better timing, tab change, ignore flow if at wrong tab ....)
image

2 Likes

True - that would initialise it every time the browser reloads the page.

1 Like

thanks for reply
In Form UI Each Text Input Have a unique Name
I Want Initialize Text Input By Value When Program Is Start

Hi
Thanks For Reply
Can you using Function Node this be done ?
Example :
msg.payload.temp;
return msg;

Simple way is to fill in the form as you want it to be - catch the payload when you submit.
Use that payload to initialise the form.

Thanks for your guide.
But it doesn't work.
My Flow =Test Form.json (1.5 KB)

It does if you set it as per what the form sends

msg.payload = {"Temp1":true,"Temp2":true}
return msg;
1 Like

A million thanks.
It worked.....