Module: alfresco/forms/controls/MaskingTextBox

alfresco/forms/controls/MaskingTextBox

This is a specialization of the TextBox that can be configured to automatically set its value to that of another form control where the value is "masked" by a Regular Expressions defined in the replacements array. This widget was written explicitly to address a requirement in the SiteService where it was necessary for a "shortName" field to automatically be updated with the value of the "title" field but with certain characters and white space removed.
Since:
  • 1.0.60
Author:
  • Dave Draper
License:
Source:

Example

This example shows how the MaskingTextBox can be used with another TextBox

{
  name: "alfresco/forms/Form",
  config: {
    pubSubScope: "FORM",
    okButtonPublishTopic: "SAVE",
    widgets: [
       {
          name: "alfresco/forms/controls/TextBox",
          config: {
             fieldId: "TEXTBOX",
             label: "Seed value",
             description: "The value of this form control is used to set that of the MaskedTextBox",
             name: "text"
          }
       },
       {
          name: "alfresco/forms/controls/MaskingTextBox",
          config: {
             fieldId: "MASKEDTEXTBOX",
             targetId: "TEXTBOX",
             label: "Resulting value",
             description: "This value will be automatically set from the value of the other TextBox",
             name: "maskedText",
             replacements: [
                {
                   regex: "[^a-z0-9\\-\\s]",
                   flags: "gi"
                },
                {
                   regex: "\\s+",
                   replacement: "-"
                }
             ],
             trim: true,
             toLowerCase: true
          }
       }
    ]
  }
} 

Members

_maskUpdateSubscription :object

This will be assigned a handle for the value change subscription created by postCreate. The subscription will be removed as soon as the user has manually changed the value.
Type:
  • object
Default Value:
  • null
Source:

replacements :Replacement[]

This should be configured to be an object array containing the
Type:
  • Replacement[]
Default Value:
  • null
Source:

targetId :string

This is the fieldId of another control in the form that this form control should use to seed its value from.
Type:
  • string
Default Value:
  • null
Source:

toLowerCase :boolean

Indicates whether or not the masked value should be converted to lower case.
Type:
  • boolean
Default Value:
  • true
Source:

trim :boolean

Indicates whether or not the masked value should have whitespace removed from the beginning and end of the value.
Type:
  • boolean
Default Value:
  • true
Source:

Methods

handleKeyUp(evt)

This extends the inherited function to remove the _maskUpdateSubscription when the user manually edits the field.
Parameters:
Name Type Description
evt object The keyup event
Source:

setMaskedValue(payload)

This function sets the value of the form control by applying each valid entry in the replacements array.
Parameters:
Name Type Description
payload object The payload containing the details of the updated value
Source:

<inner> postCreate()

This extends the inherited function to create a subscription for the changing value of the form control with the fieldId of the configured targetId.
Source: