Date & Time Fields

Capture dates, times and datetimes with validation for ranges and custom formatting.

Overview

Polyform includes three temporal field types: date for date selection, datetime for combined date and time and time for time-only inputs. All three are validated by the DateFieldValidator and support min/max constraints and custom formatting.

Date Field

Use addDate() to add a date picker. You can restrict the selectable range with min_date and max_date.

app/Actions/CreateEventForm.php

DateTime Field

addDateTime() creates a combined date and time picker, useful for appointments, bookings and scheduled events.

app/Actions/CreateBookingForm.php

Time Field

addTime() gives you a time-only input when you don't need a date.

app/Actions/CreateScheduleForm.php

Available Settings

SettingTypeDefaultDescription
min_datestringnullMinimum allowed date/datetime/time in the specified format.
max_datestringnullMaximum allowed date/datetime/time in the specified format.
formatstringY-m-dDate/time format string (PHP date format). Default varies by field type.

Validation

The DateFieldValidator checks:

  • Valid date/time format matching the field's configured format
  • Date is not before min_date (if set)
  • Date is not after max_date (if set)
  • Required/optional status based on field configuration