The issue is probably something obvious but my code looks close to the example from https://nodered.org/docs/creating-nodes/config-nodes.
Behavior:
After deploying the flow, the config node within in the select element displays the node id rather than the function result from the label.
Screenshot
Code:
<script type="text/javascript">
RED.nodes.registerType('server',{
category: 'config',
credentials: {
username: {type: "text", required:true},
password: {type: "password"}
},
defaults: {
host: {value:"localhost",required:true},
},
label: function() {
return this.host + ' (' + this.credentials.username + ')';
}
});
<script type="text/x-red" data-template-name="server">
<div class="form-row">
<label for="node-config-input-host"><i class="fa fa-server"></i> Host</label>
<input type="text" id="node-config-input-host" placeholder="Host">
</div>
<div class="form-row">
<label for="node-config-input-username"><i class="fa fa-user-circle"></i> Username</label>
<input type="text" id="node-config-input-username" placeholder="Username">
</div>
<div class="form-row">
<label for="node-config-input-password"><i class="fa fa-user-secret"></i> Password</label>
<input type="password" id="node-config-input-password" placeholder="Password">
</div>