Fields

Adonis Cockpit is currently in prerelease version. Documentation, references and examples might not be correct and are subject to change. Give your feedback.

Fields

Field Types

Boolean Field

The Boolean field represent a boolean (true/false) or a tiny integer (0/1).

import { Boolean } from "adonis-cockpit/fields";
Boolean.make("isAdmin");

You can configure custom true/false values by using trueValue and falseValue.

import { Boolean } from "adonis-cockpit/fields";
Boolean.make("checked").trueValue("on").falseValue("off");

Email Field

The Email field is a simple Text field with email validation that display a mailto: link on the index and detail views.

import { Email } from "adonis-cockpit/fields";
Email.make("email");

Password Field

The Password field displays a password input with a score.

import { Password } from "adonis-cockpit/fields";
Password.make("password");

Select Field

The Select field creates a drop-down select in the form views. The options may be defined using the options method.

import { Select } from "adonis-cockpit/fields";
Select.make("role").options(["admin", "user", "guest"]);

You may define custom labels by passing a Record<string, string> to the options method.

import { Select } from "adonis-cockpit/fields";
Select.make("role").options({
admin: "Admin",
user: "User",
guest: "Guest",
});

MultiSelect Field

The MultiSelect field is similar to the Select field but allows multiple values to be selected.

import { MultiSelect } from "adonis-cockpit/fields";
MultiSelect.make("roles").options({
admin: "Admin",
user: "User",
guest: "Guest",
});

Text Field

The Text field represents a string and displays a simple text input.

import { Text } from "adonis-cockpit/fields";
Text.make("name");