Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Checkbox

Boolean field stored as an integer (0 or 1).

SQLite Storage

INTEGER column with DEFAULT 0.

Definition

crap.fields.checkbox({
    name = "published",
    default_value = false,
})

Admin Rendering

Renders as an <input type="checkbox"> element.

Value Coercion

The following string values are treated as true: "on", "true", "1", "yes". Everything else (including absence) is false.

Special Behavior

  • Absent checkboxes are always treated as false (not as a missing/required field)
  • The required property is effectively ignored for checkboxes — an unchecked checkbox is always valid
  • Default value is 0 at the database level