Skip to main content

Calendar

Calendar widgetCalendar widget

A month-grid date picker. It collects a single normalized ISO YYYY-MM-DD string and, with no default, opens on today.

use DrevOps\Tui\Model\Weekday;

$p->calendar('harvest', 'Harvest date')
->default('2026-07-15') // Date the grid opens on.
->minDate('2026-01-01') // Earliest selectable date, inclusive.
->maxDate('2026-12-31') // Latest selectable date, inclusive.
->weekStart(Weekday::Sunday); // Day the week grid starts on.

Runnable script: playground/02-widgets/calendar.php.

Options

NameDescriptionRequiredDefault
default()Date the grid opens on, as YYYY-MM-DD.NoToday
minDate()Earliest selectable date, inclusive, as YYYY-MM-DD.NoUnbounded
maxDate()Latest selectable date, inclusive, as YYYY-MM-DD.NoUnbounded
weekStart()Day the week grid starts on, a Weekday enum case.NoWeekday::Monday

Navigation is clamped to the minDate()/maxDate() range: the cursor never leaves it, days outside it render dimmed, and an opening date outside the range snaps to the nearest bound. These are the widget's own options; the shared field options (required(), when(), validate(), ...) are covered in Field behaviour.

Keyboard

KeyAction
/ Move one day (vim: h / l)
/ Move one week (vim: k / j)
PageUp / PageDownPrevious / next month
Home / EndFirst / last day of the visible month
EnterAccept the highlighted date
EscCancel

Every move key can be remapped through the key map.

Headless behaviour

The bounds are enforced when the form runs headlessly too - a value outside the range is rejected - and surface in the JSON schema as min_date, max_date and week_start on the prompt.

Display modes

In all four display modes - Unicode or ASCII, colour on or off:

ANSINo ANSI
UnicodeCalendar: Unicode + ANSICalendar: Unicode + ANSICalendar: Unicode + No ANSICalendar: Unicode + No ANSI
ASCIICalendar: ASCII + ANSICalendar: ASCII + ANSICalendar: ASCII + No ANSICalendar: ASCII + No ANSI