Comprehensive Guide to Utilizing Fieldtypes in the Empress Framework

Introduction

Welcome to this comprehensive guide, designed to explore fieldtypes in Empress Framework. Fieldtypes are foundational elements for rendering components in desk and web forms, allowing for the input and storage of various types of data in a document.

The Importance of Fieldtypes

Fieldtypes enable developers to define the types of data that can be entered and stored in a document, providing a key aspect of the Empress Framework’s flexibility and customization ability. By understanding how to properly use and implement these fieldtypes, developers can create highly tailored software solutions that meet the specific requirements of their projects or businesses.

Understanding Fieldtypes

Data Field

A Data field is a simple text field that permits entry of a value up to 140 characters. It’s the most generic fieldtype, you can enable validations for specific types of data namely; Name, Email, Phone, or URL.

Link and Dynamic Link Fields

The Link field connects to another master from which it fetches data. The Dynamic Link field, on the other hand, can search and hold the value of any document/doctype.

Check Field

The Check field enables a checkbox. By setting the Default value to 1, it will be checked by default.

Select Field

The Select field allows for the creation of a dropdown field. All selectable values can be specified in the Options field, each value separated by a new line.

Table Field

The Table field renders another DocType as a child table within your form. This requires the chosen or defined DocType to have the Checkbox Is Child Table enabled.

Attach and Attach Image Fields

The Attach field allows for the attachment of a file from the File Manager while the Attach Image field allows for the attachment of Images in formats like jpeg, png, etc.

Text Editor Field

The Text Editor field is a text field that renders a WYSIWYG editor for input. It boasts various text-formatting options.

Date and Date and Time Fields

The Date field allows for the input of a date while the Date and Time field provides a date and time picker.

Barcode Field

The Barcode field allows for input of a Barcode number. Once entered, the Barcode automatically generates against the number.

Button Field

The Button field allows for the placement of a button in a document, enabling specific actions.

Code Field

The Code fieldtype is designed for code as input. It renders a code editor in the document form and allows for syntax validations for Python and PythonExpression.

Color Field

The Color field allows for the input of a color via a rendered color picker or direct input of a hexadecimal color.

Column Break Field

The Column Break fieldtype is a 'meta' fieldtype that doesn’t store input data but indicates a column break in the document view or form.

Currency and Float Fields

The Currency field holds numeric values like Item Price, Amount, etc. It can have a value up to six decimal places. The Float field carries numeric value, up to nine decimal places.

Geolocation Field

A Geolocation field shows a map view on which you can draw polygons, lines, and points. The data is stored as a GeoJSON feature_collection.

HTML Field

The HTML field renders the content entered in Options as HTML in the document form or view page.

Image Field

The Image field renders an image file selected in another attach field.

Int (Integer) Field

The Int (Integer) field holds numeric value, without a decimal place.

Small Text, Long Text, and Text Fields

The Small Text field carries text content and has more character limit than the Data field. The Long Text field allows for data entry with an unlimited character limit. The Text field type allows for the addition of text in the field.

Markdown Editor Field

The Markdown Editor field allows for the addition of text in markdown format.

Password Field

The Password field holds decoded value in it. This type of field can be used to store sensitive data like passwords, pass phrases, secret keys, etc.

Percent Field

The Percent field allows for the definition of a field as a Percentage field.

Rating Field

The Rating field can be used to display an interactive star rating input.

Read Only Field

The Read Only field carries data fetched from another form which will be non-editable.

Section Break and Tab Break Fields

The Section Break field is used to divide the form into multiple sections. The Tab Break field is used to divide the form into multiple tabs.

Signature Field

The Signature field allows for the addition of the Digital Signature in this field.

Table MultiSelect Field

The Table MultiSelect field is a combination of ‘Link’ type and ‘Table’ type fields.

Time and Duration Fields

The Time field allows for the definition of the Time in the field. The Duration field allows for the definition of a timespan.

JSON Field

The JSON field creates a JSON type column in your database. Also adds syntax highlighting for Desk controls.

Conclusion

Fieldtypes are vital components in the Empress Framework, enabling developers to customize their data input and storage needs. Understanding how to implement and modify these fieldtypes is crucial to the development and customization of software solutions in Empress. Whether you’re defining a simple text field or setting up a complex child table, fieldtypes offer the flexibility and adaptability to meet your development needs.