Text Box

Last update: Edit

1 Introduction

A text box is used to display and, optionally, allow the end-user to edit the value of an attribute from an object in a textual form. It can be used to display attributes of the following data types:

  • Autonumber
  • Decimal
  • Hashed string
  • Integer
  • Long
  • String

A text box must be placed in a data widget and displays an attribute of the object(s) retrieved by that widget. The name of the attribute to be displayed is shown inside the text box, between square brackets, and colored blue.

For example, the following text box allows the end-user to see, and set, the Name of a customer.

2 Properties

An example of text box properties is represented in the image below:

Text box properties consist of the following sections:

2.1 Common Section

For more information on properties in this section, see the Common Section section in Properties Common for Widgets.

2.2 Data Source Section

Attribute (Path)

Many input widgets (like text boxes and drop-down widgets) can be connected to the following:

  • An attribute of the entity of the data view that contains the widget; in this case, the widget is connected to an attribute
  • An attribute of an entity associated with the data view entity by following one or more associations of the reference type through the domain model; in this case, the widget is connected to an attribute path

In the first case, we say the widget is connected to an attribute, and in the second case it is connected to an attribute path.

In Mendix 8.0, an input widget connected to an attribute path must be read-only. Studio Pro will check this for you.

In Mendix 8.1 and above, you can edit attributes presented in input widgets over a path.

2.3 Design Properties Section

The Design Properties allow you to change spacing and alignment of the widget and hide it on phone, tablet, or desktop, if needed.

2.4 Editability Section

Editability determines whether an end-user can change the value in an input widget.

For more information on properties of this section, see the Editability Section section of Properties Common for Widgets.

2.5 Events Section

2.5.1 On Change

The on-change property specifies an action that will be executed when leaving the widget, either by using the Tab key or by clicking another widget, after the value has been changed.

For more information on properties of this section, see the Event Actions section of On Click Event & Events Section.

2.5.2 On Enter

The on-enter property specifies an action that will be executed when the widget is entered, either by using the Tab key or by clicking it with the mouse.

For more information on properties of this section, see the Event Actions section of On Click Event & Events Section.

2.5.3 On Leave

The on-leave property specifies an action that will be executed when leaving the widget, either by using the Tab key or by clicking another widget.

This differs from the On change property in that the event will always be triggered, even if the value has not been changed.

For more information on properties of this section, see the Event Actions section of On Click Event & Events Section.

2.6 Formatting Section

The formatting section applies only to the way that numeric attributes are displayed. These are attributes of the following data types:

  • Decimal
  • Integer
  • Long

Decimal Mode

This mode only applies to attributes of type Decimal.

If set to Fixed, the decimal part always will be displayed with the number of places specified in the Decimal precision property. The value will be rounded using the method defined in the rounding section of Project Settings.

If set to Auto, the whole decimal part of the attribute value will be displayed. No decimal part will be be displayed if the attribute value is an integer.

Default value: Fixed

Examples

Value Fixed (2) Fixed (4) Auto
19.0 19.00 19.0000 19
19.99 19.99 19.9900 19.99
19.9944 19.99 (*) 19.9944 19.9944
19.9999 20.00 (*) 19.9999 19.9999
19.99999 20.00 (*) 20.0000 (*) 19.99999

* The value is rounded to the nearest decimal with the defined number of decimal places.

Decimal Precision

This only applies to attributes of type Decimal and is available only when the Decimal mode is set to Fixed.

The precision of a value describes the number of decimal places that are used to express that value. This property indicates the number of decimal places (the number of digits following the point).

The way that the number is rounded when displayed is defined in the rounding section of Project Settings.

Default value: 2

Group Digits

For ease of reading, numbers with many digits before the decimal separator may be divided into groups using a delimiter when they are displayed. If the widget is editable and is the current focus of the page, then the delimiters will not be displayed.

Set Group digits to Yes to display these groups.

For example, with Group digits set to true, the number 1100100.01 will be displayed as 1,100,100.01.

Default value: No

2.7 General Section

2.7.1 Show as Password

Attributes of the data type String or Hashed string can have their value hidden. This can be used for passwords, for example, to prevent bystanders from seeing them.

Value Description
False (default) Normal text box
True Typed characters are not shown to the end-user , instead an asterisk is shown for every typed character

2.7.2 Input Mask

The input mask limits what the end-user can enter in the text box, following the rules below:

Character Allows Input of
9 any digit
Z any letter
U an upper-case letter
L a lower-case letter
* a letter or a digit

Other characters will be taken literally.

For example, the input mask 99-LLL-9999 matches 24-apr-2008.

2.7.3 Maximum Length

This property specifies the maximum number of characters that can be typed in this text box.

Value Description
Attribute length (default) The maximum number of characters is the same as the maximum length of the connected attribute
Unlimited The maximum number of characters is unlimited
Custom The maximum number of characters is specified in the widget properties

2.7.4 Placeholder Text

The placeholder text is shown when no text has been entered yet, or when a displayed attribute is empty.

It can be used, for example, to give a hint to the end-user what kind of text should be entered.

2.8 Label Section

A label describes the purpose of a widget to the end-user.

For more information on properties of this section, see the Label Section section in Properties Common for Widgets.

2.9 Validation Section

Validation Type

This property indicates whether this widget value should be validated and, if so, how. These are the possible options:

  • No validation
  • A predefined validation
  • A custom validation

The possible values of a predefined validation are the following:

  • Required – all data types
  • E-mail – string
  • Positive number – decimal, float, integer, long
  • Date in the future – dateTime
  • Date in the past – dateTime

Custom validations are expressions that follow the Microflow expression syntax. Both $currentObject and $value are in a scope that refers to the current object and the current member value, respectively. In Mendix 8.1 and above, the expression can access objects of all the data containers enclosing that data container widget. These objects are available under the name of the widget they originate from (for example, $dataView1).

When a validation is set and it fails for this widget, a message will be shown when the user selects Save.

Default value: (none)

Validation Message

This property determines the message that is shown to the user if widget validation is enabled and has failed. This is a translatable text (for more information, see Translatable Texts).

For example, if an address field is required, the validation message for the text box of the address could be something like, "The address is required."

2.10 Visibility Section

Visibility determines whether a widget is displayed to the end-user as part of the page.

For more information on properties of this section, see the Visibility Section section in Properties Common for Widgets.

3 Read More