Integrate my dropdown to my "form-submit"

Hello!

I am experimenting a bit with the dashboard again. For my usecase the form works very good. But now i have a case where i must use a dropdown too, because there are 3 options for my input.

Is its possible to "integrate" my dropdown to my submit of my form?

[
    {
        "id": "3b3f68ae8850cfdb",
        "type": "ui_form",
        "z": "eb26bb87df001a1f",
        "name": "",
        "label": "",
        "group": "fa7c1f04e5714b54",
        "order": 3,
        "width": 0,
        "height": 0,
        "options": [
            {
                "label": "Dosing",
                "value": "Dosing",
                "type": "switch",
                "required": true,
                "rows": null
            },
            {
                "label": "Remote",
                "value": "Remote",
                "type": "switch",
                "required": true,
                "rows": null
            }
        ],
        "formValue": {
            "Dosing": false,
            "Remote": false
        },
        "payload": "",
        "submit": "submit",
        "cancel": "cancel",
        "topic": "topic",
        "topicType": "msg",
        "splitLayout": "",
        "className": "",
        "x": 410,
        "y": 560,
        "wires": [
            [
                "6ba3c02bed054ea5",
                "91b254d4cf04878e"
            ]
        ]
    },
    {
        "id": "9c50ca1e7588d551",
        "type": "ui_dropdown",
        "z": "eb26bb87df001a1f",
        "name": "",
        "label": "Mode",
        "tooltip": "",
        "place": "Mode",
        "group": "fa7c1f04e5714b54",
        "order": 4,
        "width": 0,
        "height": 0,
        "passthru": true,
        "multiple": false,
        "options": [
            {
                "label": "Manual",
                "value": "Manual",
                "type": "str"
            },
            {
                "label": "Automatic",
                "value": "Automatic",
                "type": "str"
            },
            {
                "label": "Semi",
                "value": "Semi",
                "type": "str"
            }
        ],
        "payload": "",
        "topic": "topic",
        "topicType": "msg",
        "className": "",
        "x": 410,
        "y": 620,
        "wires": [
            []
        ]
    },
    {
        "id": "6ba3c02bed054ea5",
        "type": "change",
        "z": "eb26bb87df001a1f",
        "name": "SaveFormToConcept",
        "rules": [
            {
                "t": "set",
                "p": "SaveFormToConcept",
                "pt": "flow",
                "to": "payload",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 680,
        "y": 420,
        "wires": [
            []
        ]
    },
    {
        "id": "91b254d4cf04878e",
        "type": "function",
        "z": "eb26bb87df001a1f",
        "name": "assign elements_I",
        "func": "msg.payload = {\n    \"Dosing\": msg.payload.Dosing,\n    \"Remote\": msg.payload.Remote,\n}\nreturn msg; \n\n",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 670,
        "y": 460,
        "wires": [
            [
                "83af26336b9afe28"
            ]
        ]
    },
    {
        "id": "83af26336b9afe28",
        "type": "debug",
        "z": "eb26bb87df001a1f",
        "name": "Send to MQQT",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 1020,
        "y": 460,
        "wires": []
    },
    {
        "id": "fa7c1f04e5714b54",
        "type": "ui_group",
        "name": "Pump-settings",
        "tab": "a42d8adbe9caeb3d",
        "order": 3,
        "disp": true,
        "width": 14,
        "collapse": false,
        "className": ""
    },
    {
        "id": "a42d8adbe9caeb3d",
        "type": "ui_tab",
        "name": "Pumpe_01",
        "icon": "dashboard",
        "order": 1,
        "disabled": false,
        "hidden": false
    }
]

Thank you

The simple way is to save the dropdown value in a flow property, then pick it up when Submit is clicked.

1 Like

Or use a join node set to merge objects
e.g.

[{"id":"5ce1c74fcc6c399b","type":"trigger","z":"65617ffeb779f51c","name":"","op1":"","op2":"","op1type":"str","op2type":"payl","duration":"250","extend":false,"overrideDelay":false,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":2,"x":200,"y":1260,"wires":[["9c50ca1e7588d551"],["b034958fef425b81"]]},{"id":"fc225add915f780e","type":"join","z":"65617ffeb779f51c","name":"","mode":"custom","build":"merged","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"3","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":510,"y":1200,"wires":[["1cbbac35ce07cee7","5ce1c74fcc6c399b"]]},{"id":"9c50ca1e7588d551","type":"ui_dropdown","z":"65617ffeb779f51c","name":"","label":"Mode","tooltip":"","place":"Mode","group":"fa7c1f04e5714b54","order":4,"width":0,"height":0,"passthru":true,"multiple":false,"options":[{"label":"Manual","value":"Manual","type":"str"},{"label":"Automatic","value":"Automatic","type":"str"},{"label":"Semi","value":"Semi","type":"str"}],"payload":"","topic":"topic","topicType":"msg","className":"","x":430,"y":1300,"wires":[["9ee79823ebcb37aa"]]},{"id":"b034958fef425b81","type":"change","z":"65617ffeb779f51c","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.Mode","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":220,"y":1300,"wires":[["9c50ca1e7588d551"]]},{"id":"3b3f68ae8850cfdb","type":"ui_form","z":"65617ffeb779f51c","name":"","label":"","group":"fa7c1f04e5714b54","order":3,"width":0,"height":0,"options":[{"label":"Dosing","value":"Dosing","type":"switch","required":true,"rows":null},{"label":"Remote","value":"Remote","type":"switch","required":true,"rows":null}],"formValue":{"Dosing":false,"Remote":false},"payload":"","submit":"submit","cancel":"cancel","topic":"form","topicType":"str","splitLayout":"","className":"","x":290,"y":1200,"wires":[["fc225add915f780e","735e9e1fff6d2c88"]]},{"id":"9ee79823ebcb37aa","type":"change","z":"65617ffeb779f51c","name":"","rules":[{"t":"move","p":"payload","pt":"msg","to":"payload.Mode","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":610,"y":1300,"wires":[["fc225add915f780e"]]},{"id":"1cbbac35ce07cee7","type":"switch","z":"65617ffeb779f51c","name":"","property":"payload","propertyType":"msg","rules":[{"t":"hask","v":"Mode","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":670,"y":1200,"wires":[["83af26336b9afe28"]]},{"id":"735e9e1fff6d2c88","type":"junction","z":"65617ffeb779f51c","x":160,"y":1200,"wires":[["3b3f68ae8850cfdb"]]},{"id":"83af26336b9afe28","type":"debug","z":"65617ffeb779f51c","name":"Send to MQQT","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":820,"y":1140,"wires":[]},{"id":"fa7c1f04e5714b54","type":"ui_group","name":"Pump-settings","tab":"a42d8adbe9caeb3d","order":3,"disp":true,"width":14,"collapse":false,"className":""},{"id":"a42d8adbe9caeb3d","type":"ui_tab","name":"Pumpe_01","icon":"dashboard","order":1,"disabled":false,"hidden":false}]
1 Like

The Join node is the more node-red way, but personally I would use key/value format, and configure the switch to pass when the topic is that of the Submit button.

With merge you get all their payloads properties in one layer.

{"Mode":"Semi","Dosing":true,"Remote":true}

where object key will produce

{"Mode":"Semi","form":{"Dosing":true,"Remote":true}}

The join will not pass till it sees 3 properties, personnally i think it's neater, specially when you reload the form, as in my example. It may pay to reload the Mode in the join.
e.g.

[{"id":"48ae9b4c907f68d3","type":"ui_form","z":"65617ffeb779f51c","name":"","label":"","group":"ad511a617377f9b5","order":3,"width":0,"height":0,"options":[{"label":"Dosing","value":"Dosing","type":"switch","required":true,"rows":null},{"label":"Remote","value":"Remote","type":"switch","required":true,"rows":null}],"formValue":{"Dosing":false,"Remote":false},"payload":"","submit":"submit","cancel":"cancel","topic":"form","topicType":"str","splitLayout":"","className":"","x":210,"y":4020,"wires":[["ed4a9e14a4bc4963","0494cddc695c2eb2"]]},{"id":"0494cddc695c2eb2","type":"junction","z":"65617ffeb779f51c","x":80,"y":4020,"wires":[["48ae9b4c907f68d3"]]},{"id":"ed4a9e14a4bc4963","type":"join","z":"65617ffeb779f51c","name":"","mode":"custom","build":"merged","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"3","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":430,"y":4020,"wires":[["b7090084b4868c9c","b13cf6400876a2a9","99b3378e02703091"]]},{"id":"8aabbde17d1b04eb","type":"change","z":"65617ffeb779f51c","name":"","rules":[{"t":"move","p":"payload","pt":"msg","to":"payload.Mode","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":410,"y":4120,"wires":[["ed4a9e14a4bc4963"]]},{"id":"b7090084b4868c9c","type":"change","z":"65617ffeb779f51c","name":"","rules":[{"t":"delete","p":"payload.Dosing","pt":"msg"},{"t":"delete","p":"payload.Remote","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":440,"y":3940,"wires":[["ed4a9e14a4bc4963"]]},{"id":"b13cf6400876a2a9","type":"debug","z":"65617ffeb779f51c","name":"Send to MQQT","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":740,"y":3960,"wires":[]},{"id":"99b3378e02703091","type":"ui_text","z":"65617ffeb779f51c","group":"ad511a617377f9b5","order":2,"width":0,"height":0,"name":"","label":"text","format":"{{msg.payload}}","layout":"row-spread","className":"","x":610,"y":4020,"wires":[]},{"id":"3446fa50deb9f1df","type":"ui_dropdown","z":"65617ffeb779f51c","name":"","label":"Mode","tooltip":"","place":"Mode","group":"ad511a617377f9b5","order":4,"width":0,"height":0,"passthru":false,"multiple":false,"options":[{"label":"Manual","value":"Manual","type":"str"},{"label":"Automatic","value":"Automatic","type":"str"},{"label":"Semi","value":"Semi","type":"str"}],"payload":"","topic":"topic","topicType":"msg","className":"","x":210,"y":4120,"wires":[["8aabbde17d1b04eb"]]},{"id":"ad511a617377f9b5","type":"ui_group","name":"Pump-settings","tab":"a42d8adbe9caeb3d","order":3,"disp":true,"width":14,"collapse":false,"className":""},{"id":"a42d8adbe9caeb3d","type":"ui_tab","name":"Pumpe_01","icon":"dashboard","order":1,"disabled":false,"hidden":false}]
1 Like

thank you very much.

I see there are as always more options to get to the destination

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.