Text Fields
Text fields are used for collecting textual information from administrators.
KraftAdmin supports several specialized text input types that provide browser-level validation and optimized keyboards on mobile devices.
If inputType is omitted, KraftAdmin automatically infers TEXT for String properties.
Available Input Types
| Input Type | Description |
|---|---|
TEXT | Standard single-line text input |
TEXTAREA | Multi-line text |
EMAIL | Email address |
PASSWORD | Hidden password field |
TEL | Telephone number |
URL | Website address |
SEARCH | Search input |
HIDDEN | Hidden form field |
Automatic Detection
@Entity
class User(
var firstName: String,
var lastName: String
) KraftAdmin automatically renders these fields as standard text inputs.
Standard Text
@KraftAdminField(
label = "Full Name"
)
var name: String = "" Text Area
Use a textarea for long-form content.
@KraftAdminField(
inputType = FormInputType.TEXTAREA
)
var biography: String = "" Email fields use browser validation.
@KraftAdminField(
inputType = FormInputType.EMAIL
)
var email: String = "" Password
Passwords are masked while typing.
@KraftAdminField(
inputType = FormInputType.PASSWORD
)
var password: String = "" Passwords should always be hashed before storage. KraftAdmin only controls the user interface and does not perform password hashing.
Telephone
@KraftAdminField(
inputType = FormInputType.TEL
)
var phone: String = "" URL
@KraftAdminField(
inputType = FormInputType.URL
)
var website: String = "" Search
@KraftAdminField(
inputType = FormInputType.SEARCH
)
var keyword: String = "" Useful for search interfaces and filter forms.
Hidden
@KraftAdminField(
inputType = FormInputType.HIDDEN
)
var internalId: String = "" Hidden fields are included in the form but are not visible to users.
Common Configuration
Required
@KraftAdminField(
required = true
)
var username: String = "" Placeholder
@KraftAdminField(
placeholder = "Enter your username"
)
var username: String = "" Label
@KraftAdminField(
label = "Display Name"
)
var name: String = "" Read-only
@KraftAdminField(
readonly = true
)
var slug: String = "" Hide from Tables
@KraftAdminField(
showInTable = false
)
var biography: String = "" Validation
Use regular expressions to validate text.
@KraftAdminField(
regex = "^[A-Za-z ]+$",
validationMessage = "Only alphabetic characters are allowed."
)
var fullName: String = "" Sensitive Data
Sensitive values are masked in tables.
@KraftAdminField(
sensitive = true
)
var apiKey: String = "" Grouping
@KraftAdminField(
group = "Contact Information"
)
var email: String = "" Best Practices
Allow KraftAdmin to infer TEXT for ordinary strings. Only specify an inputType when a specialized control such as EMAIL, PASSWORD, or URL is required.
Use TEXTAREA for descriptions, articles, comments, and other multi-line content.
Client-side validation improves usability but should never replace server-side validation.
Related Properties
| Property | Description |
|---|---|
label | Display label |
placeholder | Placeholder text |
required | Makes the field mandatory |
regex | Validation pattern |
validationMessage | Custom validation message |
readonly | Prevent editing |
showInTable | Controls table visibility |
sensitive | Masks sensitive values |
group | Form section |
See Also
- Number
- Date & Time
- Select
- Checkbox
- WYSIWYG