Text Fields

Single-line text inputs with validation for text, email, URL, phone and password formats.

Text fields are the most common form input. Polyform includes five specialized text field variants, each with its own validation and input behavior.

Field Types

textGeneral purpose text input with optional pattern validation
emailEmail address with automatic validation
urlWeb URL with protocol validation
phonePhone number input (format validation via pattern)
passwordPassword input with masked characters

Basic Usage

Add text fields using the fluent builder methods. Each field type has its own convenience method:

app/Models/Survey.php

Available Settings

SettingTypeDescription
placeholderstringPlaceholder text shown when field is empty
min_lengthintegerMinimum number of characters required
max_lengthintegerMaximum number of characters allowed
patternstringRegular expression pattern for validation (text only)

Validation

All text fields are validated by the TextFieldValidator. You can combine multiple validation rules:

Frontend Behavior

  • Email fields show an email keyboard on mobile devices
  • URL fields show a URL keyboard with easy access to .com and /
  • Phone fields show a numeric keyboard on mobile devices
  • Password fields mask input and include a toggle to reveal the password
  • All fields show validation errors inline below the input