icon Text

The Text control is used to add text to your form, for information that you want to convey to the user. This is a rich text control, so you can also include links, images, different types of formatting with your text.

This page contains a detailed description of the control properties and JavaScript samples which you can use with this control.

Text control

Properties

Here you can find properties specifically related to the Text control.

Name

A unique identifier for the control.

Name property

JavaScript

The Name property allows to work with the control via JavaScript code, like this:

fd.rendered(function(){
    //can access the control using its Name:
    fd.control('Text1').html = 'New text for the Text control';
 });

Width

The property defines the width of the control in pixels.

If left blank, the control takes up the entire available width in the current grid cell.

Width property

Text

Opens an editor where you can input all the text:

Open Text property

Many options are available for formatting the text. You’re also able to insert images and links into the text:

Text property

Class

Add a CSS class to the control, which comes in handy with CSS or even JavaScript code. This will work as a class attribute for an HTML tag.

Control's class

The same class can be applied to multiple fields and controls, and then you can use CSS to modify the appearance of these. For example, here we’ve used the following CSS code in the CSS editor to give controls with my-class a blue background, white text and rounded corners, change link color to yellow, and add a little bit of padding:

.my-class {
    color: #FFFFFF;
    padding: 10px;
    background-color: #1E90FF;
    border-radius: 30px;
}

.my-class a {
    color: #FFCC00;
}

.my-class a:hover{
    color: #FFE100;
}

Control's class with CSS on the form

Style

Add custom CSS style to the control. This will work as a style attribute for an HTML tag.

Control's style

You can apply different styles to the control. For example, the following style will allow you to add a thin gray border around the control:

padding: 10px;
border: 1px solid #CED4DA;

JavaScript

In this section, you can find basic examples of how to work with the control using JavaScript.

If you are not familiar with the JavaScript framework, get started with the JavaScript basics.

Note

The control is only accessible once the form is rendered, so all calls to the control must be inside fd.rendered event:

fd.rendered(function(){
    //hide the control
    $(fd.control('Control1').$el).hide();
    //show the control
    $(fd.control('Control1').$el).show();
});

Get or set text

Get or set the text and content with the following property:

//return the text as a string with HTML formatting
fd.field('Control1').html;

//set the text as a string with HTML formatting
fd.control('Control1').html = '<h1>New text for the Text control</h1>';

Get HTML element

Access HTML element inside the control in order to modify it, hide it, or do something else.

//access control's HTML
var htmlControl = fd.control('Control1').$el;