Skip to content

Properties Reference

Every field in a model is defined as a Property object. This page lists all available property types with examples.

Common options

All properties share options like ->required(), ->readonly(), ->label(), ->placeholder(), and more. See Common Property Options for the full list.

Text & String

StringProperty

Single-line text input.

1
2
3
4
5
6
use System\StringProperty;

new StringProperty('name')                             // basic text field
(new StringProperty('title'))->autofocus()             // focused on page load
(new StringProperty('tags'))->asArray()                // multiple values as tag pills
(new StringProperty('code'))->placeholder('e.g. AB-001')

TextProperty

Multi-line textarea with optional rich editing variants.

use System\TextProperty;

new TextProperty('notes')                              // plain textarea
(new TextProperty('notes'))->rows(8)                   // taller textarea

// Rich editing variants
(new TextProperty('content'))->asRichtextEditor()      // WYSIWYG editor
(new TextProperty('readme'))->asMarkdown()             // Markdown with preview
(new TextProperty('snippet'))->asCode('php')           // Syntax-highlighted code
(new TextProperty('diagram'))->asDiagramEditor()       // Mermaid diagram editor

PasswordProperty

Masked input. Never echoes the stored value back to the form.

1
2
3
use System\PasswordProperty;

new PasswordProperty('secret')

Numbers

IntegerProperty

Whole numbers.

1
2
3
4
use System\IntegerProperty;

new IntegerProperty('quantity')
(new IntegerProperty('scores'))->asArray()             // multiple integers

DecimalProperty

Precise decimal numbers with configurable decimal places.

1
2
3
4
use System\DecimalProperty;

new DecimalProperty('weight')                          // default: 2 decimals
(new DecimalProperty('rate'))->decimals(4)

CurrencyProperty

Formatted currency amount with symbol.

1
2
3
4
use System\CurrencyProperty;

new CurrencyProperty('price')                          // default: EUR, 2 decimals
(new CurrencyProperty('total'))->currency('$')->decimals(2)

PercentProperty

Percentage value (0–100) with % suffix.

1
2
3
4
use System\PercentProperty;

new PercentProperty('discount')
(new PercentProperty('tax_rate'))->decimals(1)

RangeProperty

Slider input between min and max.

1
2
3
4
use System\RangeProperty;

(new RangeProperty('satisfaction'))->min(1)->max(10)
(new RangeProperty('volume'))->min(0)->max(100)->step(5)

NumericWithUnitProperty

Number with a unit selector (length, weight, etc.).

use System\NumericWithUnitProperty;
use System\UnitSets;

new NumericWithUnitProperty('height', UnitSets::LENGTH_1D, defaultUnit: 'm')

// Custom units
new NumericWithUnitProperty('weight', [
    'kg' => 'Kilograms',
    'lb' => 'Pounds',
], defaultUnit: 'kg', decimals: 1)

Dates & Time

DateProperty

Date picker (stored as YYYY-MM-DD).

1
2
3
4
use System\DateProperty;

new DateProperty('birthday')
(new DateProperty('milestones'))->asArray()            // multiple dates

TimeProperty

Time picker (stored as HH:MM).

1
2
3
use System\TimeProperty;

new TimeProperty('start_time')

DateTimeProperty

Combined date and time picker.

1
2
3
use System\DateTimeProperty;

new DateTimeProperty('event_start')

MonthProperty

Month picker (stored as YYYY-MM).

1
2
3
use System\MonthProperty;

new MonthProperty('billing_month')

WeekProperty

ISO week picker (stored as YYYY-Www).

1
2
3
use System\WeekProperty;

new WeekProperty('sprint_week')

DateRangeProperty

Date range with from/to pickers. Highly configurable.

use System\DateRangeProperty;

new DateRangeProperty('period')

// With time selection
(new DateRangeProperty('shift'))
    ->withTimePicker()
    ->withTimePickerIncrement(15)

// With predefined ranges
(new DateRangeProperty('report_period'))
    ->withRanges([
        'Today'     => ['today', 'today'],
        'This Week' => ['monday this week', 'sunday this week'],
        'This Month'=> ['first day of this month', 'last day of this month'],
    ])

// Calculated range (read-only)
(new DateRangeProperty('contract_period'))
    ->setReadonly(true)
    ->setFunction(function ($record) {
        return [$record->start_date, $record->end_date];
    })

Selection

SelectProperty

Dropdown with static options.

1
2
3
4
5
6
7
use System\SelectProperty;

new SelectProperty('status', [
    'active'   => 'Active',
    'inactive' => 'Inactive',
    'archived' => 'Archived',
])

MultiSelectProperty

Multiple selections stored as JSON array.

1
2
3
4
5
6
7
use System\MultiSelectProperty;

new MultiSelectProperty('categories', [
    'billing'  => 'Billing Address',
    'shipping' => 'Shipping Address',
    'mailing'  => 'Mailing Address',
])

BooleanProperty

True/false toggle.

1
2
3
4
5
use System\BooleanProperty;

(new BooleanProperty('is_active'))->asSwitch()         // toggle switch (default)
(new BooleanProperty('newsletter'))->asCheckbox()      // classic checkbox
(new BooleanProperty('approved'))->asSelect()          // Yes/No dropdown

Contact Fields

EmailProperty

Email address with clickable mailto: link.

1
2
3
4
use System\EmailProperty;

new EmailProperty('contact_email')
(new EmailProperty('watchers'))->asArray()             // multiple emails

TelProperty

Phone number with clickable tel: link.

1
2
3
4
use System\TelProperty;

new TelProperty('mobile')
(new TelProperty('phones'))->asArray()

UrlProperty

URL with clickable link (opens in new tab).

1
2
3
4
use System\UrlProperty;

new UrlProperty('website')
(new UrlProperty('links'))->asArray()

Files & Media

FileProperty

General file upload.

1
2
3
4
5
use System\FileProperty;

new FileProperty('attachment')
(new FileProperty('documents'))->asArray(1, 5)         // 1–5 files
(new FileProperty('specs'))->accept('pdf,doc,docx')    // restrict file types

ImageProperty

Image upload with preview. Restricted to image formats.

1
2
3
4
use System\ImageProperty;

new ImageProperty('avatar')
(new ImageProperty('gallery'))->asArray()->max(10)

PdfProperty

PDF-only upload with modal viewer.

1
2
3
4
use System\PdfProperty;

new PdfProperty('contract')
(new PdfProperty('attachments'))->asArray(0, 3)        // 0–3 PDFs

Calculated & Display-Only

These properties have no input field — they display computed values.

StringPropertyCalculated

Read-only computed string.

1
2
3
4
5
6
7
8
9
use System\StringPropertyCalculated;

// Plain text
new StringPropertyCalculated('greeting', fn($record) => "Hello, {$record->name}!")

// HTML output
new StringPropertyCalculated('fullname', function ($record) {
    return '<b>' . strtoupper($record->lastname) . '</b>, ' . $record->firstname;
}, isHtml: true)

NumericPropertyCalculated

Read-only computed number.

1
2
3
4
5
6
7
8
use System\NumericPropertyCalculated;

new NumericPropertyCalculated('age', function ($record) {
    if (!$record->dateofbirth) return '';
    $birth = new \DateTime($record->dateofbirth);
    $now = new \DateTime();
    return (string) $birth->diff($now)->y;
})

TextPropertyCalculated

Read-only computed text block with optional rendering variant.

1
2
3
4
5
use System\TextPropertyCalculated;

// Generated code preview
(new TextPropertyCalculated('preview', fn($record) => $record->generateCode()))
    ->asCode('php')

Special Types

TodoListProperty

Interactive checklist with add/remove/check controls.

1
2
3
use System\TodoListProperty;

new TodoListProperty('tasks')

Initialize items in beforeNew():

1
2
3
4
5
6
7
8
protected function beforeNew(): void
{
    $this->getProperty('tasks')?->fromTexts([
        'Review requirements',
        'Write implementation',
        'Run tests',
    ]);
}

Check progress:

1
2
3
4
5
$todo = $this->getProperty('tasks');
$todo->getProgress();    // 0–100 (percentage)
$todo->isComplete();     // true if all checked
$todo->getDoneCount();   // number of checked items
$todo->getCount();       // total items

ColorProperty

Color picker with optional palette.

1
2
3
4
use System\ColorProperty;

new ColorProperty('brand_color')
(new ColorProperty('theme'))->palette(['#ff0000', '#00ff00', '#0000ff'])

QRCodeProperty

Auto-generated QR code.

1
2
3
use System\QRCodeProperty;

(new QRCodeProperty('qrcode'))->asRecordUrl()  // QR code linking to this record

StateProperty

Enables the workflow state machine. See Workflow & State Machine.

1
2
3
use System\StateProperty;

new StateProperty()

Convention Properties

These are framework-managed properties that add system features. They are included automatically by DefaultModel, but you can add them manually in a base Model:

use System\SoftDeleteProperty;
use System\RecordLockProperty;
use System\AuditCreatedProperty;
use System\AuditModifiedProperty;

// Included automatically by DefaultModel:
new SoftDeleteProperty()       // soft delete with trash
new RecordLockProperty()       // checkout/check-in locking
new AuditCreatedProperty()     // created_by + created_on
new AuditModifiedProperty()    // modified_by + modified_on

Versioning

Enable JSON snapshots on check-in:

$this->enableVersioning()      // returns a VersioningProperty

Audit Trail

Track field-level changes:

$this->track()                 // track all user-defined fields
$this->track(['name', 'email']) // track specific fields only