When we adding the mqtt-in or mqtt-out nodes we obtain a server field with select list and a button which can add new servers to the list
.
Please, help me change the functionality of the button with pencil instead of default.
This is what's known as a config node, how to create config nodes is described in the Node-RED documentation here: https://nodered.org/docs/creating-nodes/config-nodes
The important bit is the type of the of the config option:
<script type="text/javascript">
RED.nodes.registerType('mqtt in',{
category: 'input',
defaults: {
name: {value:""},
topic: {value:"",required:true,validate: RED.validators.regex(/^(#$|(\+|[^+#]*)(\/(\+|[^+#]*))*(\/(\+|#|[^+#]*))?$)/)},
qos: {value: "2"},
broker: {type:"mqtt-broker", required:true}
},
color:"#d8bfd8",
inputs:0,
outputs:1,
...
As you can see the broker
field has a type of mqtt-broker
. The mqtt-broker
node is a separate node with a category of config
.
There are plenty of examples of this type of pattern in the core nodes that ship with Node-RED including the MQTT or serial port nodes.