Fields
A field decides three things at once. The column in Postgres, the control in the admin, and the validation on the way in. This page is the table of every type, with a page each for the detail.
| Field | Column | Admin control |
|---|---|---|
f.text(255) | varchar(255), or text in text mode | input |
f.textarea() | text | multi-line box |
f.email() | varchar(255) | email input |
f.url() | varchar(2048) | input |
f.number() | integer, or the size you name | number input |
f.boolean() | boolean | switch |
f.date() | date | date picker |
f.datetime() | timestamp(3) with time zone | date and time |
f.time() | time(0), no time zone | time picker |
f.select() | varchar sized to the longest option | select |
f.object() | jsonb | nested form |
f.json() | jsonb, or json if you ask | code editor |
f.upload() | varchar(36) pointing at your assets | file picker |
f.richText() | jsonb, or text in markdown mode | editor |
f.blocks() | jsonb | block canvas |
The last two come from @questpie/admin and appear on f only when that module
is enabled. Everything above them is core questpie.
Blocks has its own page.
Reading the table
The column is what you get in Postgres. Change f.text(255) to
f.text(500), run the generator, then push, and the column widens with it. Most
types take an argument that moves the column, and each page says which.
The control is what a person sees. You do not pick it. The admin reads the field type and chooses, which is the reason you declare a type rather than a widget.
Any field can be localized. .localized() is declared once on the base
field class, so it works on every row of the table rather than a blessed subset.
Lists of one type
There is no f.array(). .array() is a chain method you put on any field, and
it turns that field's column into jsonb holding a list.
tags: f.text(50).array(),Arrays covers what that does to reads, writes and filters.
Related
Temporal values covers what date,
datetime and time actually store, and what comes back out.
Relations covers pointing at another table. It is not a field type, it is its own thing.