What is an Uitype?

Definition

An uitype is a graphical element used to represent a form field and format its value according to a context.

Uccello allows you to create forms made up of fields of different types. Each field type corresponds to a uitype.

Each uitype is autonomous, independent and able to format data:

  • In a database

  • In a vue

  • In table cells

  • In the response to an API call

Similarly, each uitype is able to generate a form field to display on an edit page.

Flexible

Thanks to the high flexibility of uccello, it is possible to create simplistic uitypes (a simple value) as well as complex uitypes (display using external libraries).

For example, the text uitype only displays plain text while the entity uitype is able to link one data to another that may be located in a different module. The date uitype allows you to select a date from a calendar.

Configurable

The configuration of a uitype is done at several levels.

  • migration file: Type of the column in the database and type of field used in the form

  • php class: Formatting the value when saving and displaying

  • blade files : Displaying the form field and defining a layout in a view

Let's take the example of the text uitype:

Migration file

$table->string('name') : Creta a column namedname with type VARCHAR(255)

'uitype_id' => uitype('text')->id : The field uses the text uitype

Php class

The text uitype is defined in the file app/Fields/Uitype/Text.php. Here is a summary after integration of the traits used.

Blade files

There are at least four blade files per uitype. One for the layout of the form field in the edit view, one for displaying the field value in the detail view, one for searching from the list view and one for displaying the field value in the list view.

By default, the text uitype uses blade files:

  • resources/views/modules/default/uitypes/edit/text.blade.php

  • resources/views/modules/default/uitypes/detail/text.blade.php

  • resources/views/modules/default/uitypes/list/text.blade.php

  • resources/views/modules/default/uitypes/search/text.blade.php

Here is the content of the file resources/views/modules/default/uitypes/detail/text.blade.php.

Notice the use of the method getFormattedValueToDisplay(Field $field, $record) defined in thephp class.

Expandable

Thanks to the fact that each uitype is autonomous and independent, it is possible to create new ones and share them with the uccello community.

Default Uitypes

Uccello's default uitypes are found in the directory vendor/uccello/uccello/app/Fields/Uitype.

To get an overview of all native uitypes, you can go to the Default Uitypes page.

Last updated

Was this helpful?