Auto-fill configui textfield based on menu selection

Posted on
Sat Apr 23, 2016 3:24 pm
FlyingDiver offline
User avatar
Posts: 7222
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Auto-fill configui textfield based on menu selection

I have Device definitions that contain the following fields:

Code: Select all
         
<Field type="menu" id="encryptionType" defaultValue="SSL">
   <Label>Encryption:</Label>
   <List>
      <Option value="None">None</Option>
      <Option value="SSL">SSL</Option>
   </List>
</Field>
<Field id="hostPort" type="textfield" defaultValue="993">
         <Label>Server Port:</Label>
</Field>


Right now, I set the default values on both fields to match. But I'd like to fill in a different default value if the user selects a different Option in the menu control. Is there any way to do that?

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Sat Apr 23, 2016 7:16 pm
jay (support) offline
Site Admin
User avatar
Posts: 18225
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Auto-fill configui textfield based on menu selection

You can't change the default, but you can change the value. Make the menu a dynamic reload - that will call the method you supply any time the menu changes. You can then return a changed valuesDict with the new value for the text field.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Sat Apr 23, 2016 7:55 pm
FlyingDiver offline
User avatar
Posts: 7222
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Auto-fill configui textfield based on menu selection

I think I see what you're talking about. Now I'm going to hope someone volunteers some sample code before I try to create it from scratch. ;)

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Sun Apr 24, 2016 6:09 am
FlyingDiver offline
User avatar
Posts: 7222
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Auto-fill configui textfield based on menu selection

OK, I've got the menu list populating, and I have the text field updating when the user selects from the popup.

Is there a way to set a default selection for the menu popup? When I create a new device, nothing is selected. I'd really like to have a default set.

Thanks!

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Sun Apr 24, 2016 6:23 am
autolog offline
Posts: 3991
Joined: Sep 10, 2013
Location: West Sussex, UK [GMT aka UTC]

Re: Auto-fill configui textfield based on menu selection

Hi Joe,
I think you want to have the following routine (or similar):
Code: Select all
   #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
   # This routine returns the UI values for the device configuration screen prior to it
   # being shown to the user; it is sometimes used to setup default values at runtime
   #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
   def getDeviceConfigUiValues(self, pluginProps, typeId, devId):
      self.debugLogWithLineNum(u'Called getDeviceConfigUiValues(self, pluginProps, typeId, devId):')
      if self.logMethodParams == True:
         self.debugLogWithLineNum(u'     (' + unicode(pluginProps) + u', ' + unicode(typeId) + u', ' + unicode(devId) + u')')
      return super(Plugin, self).getDeviceConfigUiValues(pluginProps, typeId, devId)

This extract lifted from the Plugin Developer Documenter plugin which Adam (RogueProeliator) produced.
If you haven't done so already, I highly recommend downloading it and investigating the code - it is very helpful for plugin developers. :D

Posted on
Sun Apr 24, 2016 7:27 am
FlyingDiver offline
User avatar
Posts: 7222
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Auto-fill configui textfield based on menu selection

Thanks all, I think I've got it now.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 12 guests