Skip to main content

Calendar

Calendar widgetCalendar widget

A month-grid date picker. It collects a single normalized ISO YYYY-MM-DD string; give it no default and it 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 behavior.

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

The day and week moves resolve through the key map, so the arrows and the vim letters can be remapped; the month and edge jumps (PageUp/PageDown, Home/End) are fixed keys with no action behind them.

Headless behavior

The bounds are enforced when the form runs headlessly too - a value outside the range is rejected - and they 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, color 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