Table Of Contents
 

How To: Make Custom Interfaces

The 20 or so built-in interfaces that come with UDI usually suffice, but occasionally you may come across a unique situation where you need to do something strange or provide a custom type of interface for editing a field. Here's how to do just that.

To Make a Custom Interface for UDI


In this example, we will make a copy if the text field with some extra functionality to lookup the default user password from another table, depending on the user currently being edited (This was actually a real-world situation that came in from the support forums).
  1. First get the very latest version of UDI from source control.

  2. Now copy the interfaces/text folder to a new folder in the root of your application called "interfaces" and then rename the copied "text" folder to "custompassword" so you end up with so you end up with interfaces/custompassword.

    So to clarify, your directory structure will look like

    Application.cfm
    dccom/
    custominterfaces/
    ..

    And custominterfaces/ will contain:

    custompassword/

  3. Now modify the code where you call UDI - change the line<cf_dccom field="userpassword" type="text" display="Password"></cf_dccom>

    to

    <cf_dccom field="userpassword" type="custompassword" interfacePath="..\..\..\custominterfaces\" display="Password" required="yes"></cf_dccom>

  4. OK, now you have a fully working custom field which is an exact copy of the existing "text" type. All you have to do is modify the code to pull in your default password.

    Open custominterfaces/custompassword/interface.cfm and insert something like the following before interface cfoutput tag:

    <cfif Len( dbFieldVal ) IS 0 AND isdefined( UserID )>    <cfquery datasource="myDSN" name="getDefaultPassword">    SELECT  userpassword FROM TABLE
    WHERE  UserID = #UserId#
    </cfquery>
    <cfif getDefaultPassword.recordCount>
        <cfset dbFieldVal = getDefaultPassword.userpassword>
    </cfif>
    </cfif>