Fieldia

Fields

Every field has a type: what kind of value it holds. A field node can pick a widget, how that value is shown, and give it options. Leave the widget out and the type's own is used.

TypeHoldsWidgetsOptions of its own
charOne line of textemail, phone, url, password, tags (free text), time (HH:MM), color (#rrggbb), copy, embed (a page shown inline), repeat (an iCalendar repeat rule), one-time-code (a box per digit), qrcode, barcode (a code to scan), code (with @fieldia/code), monaco (with @fieldia/monaco)size, pattern (the whole answer), patternHint, translate, requiredIn
textSeveral lines of textcopy, qrcode, code (with @fieldia/code), monaco (with @fieldia/monaco)size, translate, requiredIn
htmlFormatted text with a toolbar, cleaned of scripts on every change—translate, requiredIn
integerA whole numberrating (stars), scale (1 to 10 buttons), progressbar, label, color (a tag colour, 0 to 11), barcodemin, max
floatA decimal numberprogressbar, label, duration (HH:MM), percentage, timer, place (a latitude, with @fieldia/map)min, max, digits
monetaryAn amount of moneyprogressbar, labelcurrencyField or currency, min, max, digits, money
booleanYes or notoggle, priority (one star)—
dateA date — or a month alone, or a year alonedaterangemin, max, days, precision, hijri
datetimeA date and a time, kept as an instantdaterange, timer, slots (booking a time from those free)min, max, days, timeZone
selectionOne choice from a list, or several with multipleradio, checkboxes, statusbar, priority (stars), dot (a state’s dot)options, multiple, optionsFrom
many2oneA link to one record of another model, found by typingstatusbar, path (a record of a tree as its path)relation, filter
many2manyLinks to several recordstags, checkboxes, tree (several records of a tree, ticked)relation, filter
one2manyA table of lines that belong to this record—relation, fields, columns on the node
referenceA link to a record of one of several models—models
binaryA file, uploaded or dropped; several with multiple, as a list, thumbnails or cards, each opening in a viewerpdf (shown inline)accept, maxSize, multiple, minFiles, maxFiles, shrink
imageAn image, with a preview; several with multiple, as thumbnails, cards or a list—maxSize, multiple, minFiles, maxFiles, shrink
jsonStructured data, checked as it is typedcode (with @fieldia/code), monaco (with @fieldia/monaco), place and area (with @fieldia/map), address, pins (on a picture), distribution, tax-totals, payments, hours (a week’s opening hours)—
propertiesExtra values, each edited with the field for its type—definitions, definitionsFrom

Every type also takes label, help, required, readonly and default. To see them all at once, open the every-field demo.

A date's min and max are its earliest and latest day: a day, "2026-03-02", or one counted from the day the form is opened, "today", "today+30", "today-7"; a date and time keeps them by the day it falls on. days are the days of the week it may fall on, ISO numbers from 1, Monday, to 7, Sunday: [1, 2, 3, 4, 5] refuses a weekend of Saturday and Sunday, [7, 1, 2, 3, 4] one of Friday and Saturday. A date's default may be "today". A field with the widget email, url, phone or time is checked as one, and says what to type.

A month alone, a year alone, and the Hijri calendar

A date of a month alone — a billing period, a card's expiry — says "precision": "month", and of a year alone — a building's year — "precision": "year". Its box takes a month as people write one — 10/2026, 2026-10, Oct 2026, أكتوبر ٢٠٢٦ — or four digits, and keeps its first day, "2026-10-01", as every backend keeps a date; at rest it shows Oct 2026 or 2026, and so does a list. Its button opens a year's twelve months, or twelve years. A whole day typed or pasted gives its month, the day it leaves out said. Its min and max are kept by the month or the year: with "min": "today", this month is still within it.

A date with "hijri": true is shown and typed in the Hijri calendar beside the Gregorian day it keeps, by Umm al-Qura's reckoning, as your browser's Intl keeps it: a second box reads 2 Jumada I 1448 AH at rest — 2 جمادى الأولى 1448 هـ on an Arabic page — and 02/05/1448 while it is typed in, in the page's order; a day typed in either box writes the other. A Hijri month has 29 or 30 days as Umm al-Qura says, and a day past them is said with the days it has, the field keeping the day it held. Its calendar shows each day's Hijri day under it; a list writes both days. The value stays the Gregorian day.

"first_rent": { "type": "date", "label": "First rent's month", "precision": "month", "min": "today" },
"built": { "type": "date", "label": "Building built in", "precision": "year", "max": "today" },
"starts_on": { "type": "date", "label": "Starts on", "hijri": true }

In the designer: a date's Keeps (a day, a month, a year) and Hijri date beside it. Open the lease demo.

Options with a second line, an icon or a colour

A choice's options may say more than their words: a caption — a second line under them, a service's length and price, a plan's limits — an icon, by the name of one of Fieldia's icons (or your app's), and a color, #rrggbb, a dot beside them. Radios and checkboxes show them; a dropdown whose options have any is Fieldia's own list, never the browser's, which shows one line of words; a list that searches shows them too. Each option is still named by its words, its second line read after them.

"plan": { "type": "selection", "label": "Paid", "options": [
  { "value": "monthly", "label": "Monthly", "caption": "12 payments, on the first of each month", "icon": "calendar" },
  { "value": "yearly", "label": "Once a year", "caption": "1 payment, 3% off the rent", "icon": "money", "color": "#30c381" }
] }

A link's suggestions show what your data source gives of each record (what a link shows): its picture, or its colour as Flectra numbers them, before its name; its first line of details under it — a staff member's role, a service's price — and its aside at the row's end. Each is named by its record's name alone, as it always was; what it shows besides describes it, read after the name. In the designer: a choice's Describe the options, then each option's Second line, Icon and Colour. Open the booking template.

Masks and one-time codes

A char field's node may type it to a mask — a national ID, an IBAN, a car plate: 9 is a digit, in any script, a a letter, * either, \ before a character that character itself, and [ ] round its end what may be left out; every other character is the mask's own, written in as the person types, and Backspace over one takes the character before it. A key no slot takes there is refused with why — a digit goes here, not “x” — said while the keys after it go in where they fit, never hidden; a paste is laid out against the mask, one with words round the value (ID 1023456789, IBAN: SA03 …) gives the one value in them, and one with none, or two, is refused whole, saying why. The field takes the characters typed once every slot it needs is filled, or as shown with "maskKeeps": "shown"; "upper": true writes its letters in capitals. Left before it is whole, what was typed stays, marked, with how many are still to type.

{ "type": "field", "id": "f-id", "field": "national_id", "options": { "mask": "9 999 999 999" } },
{ "type": "field", "id": "f-iban", "field": "iban", "options": { "mask": "aa99 **** **** **** **** **[** **** **** **]", "upper": true } },
{ "type": "field", "id": "f-plate", "field": "plate", "options": { "mask": "9999 aaa", "upper": true, "maskKeeps": "shown" } },
{ "type": "field", "id": "f-code", "field": "code", "widget": "one-time-code", "options": { "length": 6 } }

A number or an amount with "shorthand": true in its node's options is typed as agents write big amounts: 3.5m, 500k, 1.2bn, ٣٫٥ مليون, 3,5 Mio. — read on the digits, its word the power of ten it names in the page's language or English, and k, m and b anywhere. As it is typed the box says 3.5m is 3,500,000; once left, it shows the whole amount. Open the listing demo and type a price of 6m.

"widget": "one-time-code" draws a box for each digit — length 4 to 12, 6 unless said; letters for letters too — over one text box the phone's autofill of a code sent by SMS fills whole (autocomplete="one-time-code"); a code pasted with its spaces or dashes lands across the boxes — a whole message pasted gives the one code of its length in it — and a screen reader reads one box by its label. The field takes the code once it is whole, so a step on its change can send it. In the designer: a short answer's Mask and Letters in capitals; the kind One-time code, with its Digits and Letters too.

A checkbox tree

A many2many with "widget": "tree" picks several records of a tree at once — the areas a buyer wants, a doctor's specialties, a role's permissions — as a tree of boxes to tick. A branch's box is ticked when all under it are and part-ticked when some are; ticking it ticks all under it. Its records are the link's, each placed by its path, as the path picker's are (see what a link shows). What the field keeps is keeps: every record ticked ("all", unless said, a branch's own record too once all under it are), a whole branch as its own record alone ("top": all of Nasr City kept as Nasr City), or the records with none under them alone ("leaves"). A record the value holds that the tree does not show is kept as it is.

A search over the tree keeps the rows whose names have the words, with the branches they are in, open ("search": false leaves it out); how many are chosen is said under it. It is used as a tree: ↓↑ move, → opens a branch or goes into it, ← closes it or goes up (the other way round right to left), Home and End, Space ticks, and typing a name's first letters goes to it.

"areas": { "type": "many2many", "label": "Areas wanted", "relation": "area" }

{ "type": "field", "id": "f-areas", "field": "areas", "widget": "tree", "options": { "keeps": "top" } }

In the designer: a link to several records' A tree to tick, with its Keeps and A search over it. Open a lead: his areas wanted are a tree.

Phone numbers the world over

A phone field is a text box until its page says how phone numbers are read: "phone", with the country a number typed without its + is read in, and whether a number is shown at rest abroad's way, "international" (the default), or at home's, "national". A field can say it for itself in its options, which win over the page's.

{
  "fieldia": "0.13",
  "phone": { "country": "EG", "shown": "national" },
  "fields": { "mobile": { "type": "char", "label": "Mobile" }, "office": { "type": "char", "label": "Dubai office" } },
  "layout": { "type": "sections", "id": "s", "children": [
    { "type": "field", "id": "f-mobile", "field": "mobile", "widget": "phone" },
    { "type": "field", "id": "f-office", "field": "office", "widget": "phone", "options": { "country": "AE" } }
  ] }
}

The country table — every country's dialling code, the lengths its numbers have by how they start, and how they are written in groups — is made from libphonenumber's metadata and comes with the box in a part of its own, fieldia.phone.js (19 KB gzipped), the first time a page shows such a phone; libphonenumber's own smallest build is 34. A page that says nothing of phones never downloads it. In the designer: the screen's Phone numbers, Phone country to start on and Phone numbers shown; a phone field's Country to start on and Shown.

One text in several languages

A listing's title read on a portal in Arabic and in English, a service's name on a clinic's site in both: a line, a paragraph or formatted text says the languages it is kept in, translate, each typed by a person — Fieldia never translates it, nor offers to. Its value is an object of each language's text by its tag, a language not typed yet left out, none typed no value at all.

{
  "fields": {
    "title": { "type": "char", "label": "Title", "translate": ["ar", "en"], "required": true, "size": 80 },
    "description": { "type": "text", "label": "Description", "translate": ["ar", "en"], "required": true, "requiredIn": ["en"] }
  }
}

// its value, as the data source loads and saves it
{ "title": { "ar": "شقة بإطلالة على النيل", "en": "Nile-view flat" }, "description": { "en": "Three bedrooms." } }

It comes in a part of its own, fieldia.languages.js, with its checks, the first time a page with one is shown; a page with none never downloads it. A table's line keeps one language. In the designer: a short answer's, a paragraph's or formatted text's Typed in several languages, its languages, and, while it is required, Required in. See a listing in Arabic and English, and a clinic's services named in both.

A list whose cells change in place never opens such a field's cell — its languages are typed under the switch, on the record's page — and AI help fills the one language the person is looking at, never the others (AI help). Such a text is typed as words: a mask or shorthand on it is refused, a link's words fill none of its languages, a record template keeps it whole and lays both, and pageFromSchema keeps the languages Fieldia's own fields name (a backend's translate: true is typed in one, said in its notes). Not done yet, for 0.29: the exported matchesFilter judges one text (the memory source finds a record by any of its languages); Export writes the reader's language alone, and Import reads one text, taken as the first language; the quiet look leaves the switch's tabs boxed; a map's pins and cards show the reader's language without its mark.

Scanning a code with the camera

A field whose node says options.scan gets a Scan button at the end of its box: a line of words, a paragraph, a link to another record, a table's column, or a table of lines that counts what is scanned. The camera opens in a sheet over the page — the back camera on a phone — and a code read fills the field, with a beep where the browser lets it and a buzz on a phone; Escape, × and Type it instead close it, and the camera stops the moment it closes. It reads QR codes, DataMatrix, EAN-13 and EAN-8, UPC-A and UPC-E, Code 128 and Code 39 — formats keeps it to some, and a code of another kind held up is said: “This code has no Lot in it.” A scanner gun plugged in types into the box, and what it typed is read as the camera reads it once Enter is pressed or the box is left — a patient found by her card's code, a box's code filling the product, the lot and the expiry — while words a person types stay as typed. A table counted by scanning has a box in its sheet to type a code whose label will not scan.

{ "type": "field", "id": "f-patient", "field": "patient_id", "options": { "scan": { "by": "card" } } },
{ "type": "field", "id": "f-lines", "field": "line_ids", "columns": ["product_id", "lot", "expiry"],
  "cells": { "lot": { "options": { "scan": {
    "formats": ["data_matrix"], "part": "10",
    "fills": { "expiry": "17", "product_id": { "part": "01", "by": "gtin" } } } } } } },
{ "type": "field", "id": "f-count", "field": "count_ids",
  "options": { "scan": { "field": "product_id", "count": "counted", "by": "barcode" } } }

Where the browser reads codes itself (BarcodeDetector: Chrome on Android, ChromeOS and macOS) nothing more is downloaded. Elsewhere — Safari on an iPhone, Firefox, Chrome on Windows and Linux — ZXing's readers come in a part of their own, fieldia.decode.js (39 KB gzipped), the first time Scan is pressed there. The button and the sheet are fieldia.scan.js (9 KB gzipped), loaded with a page that scans. An app with its own scanning library hands it over with useCodeReader. In the designer: a field's Scan with the camera, and for a link the field its records keep their code in. Try it on a clinic's treatment and a shelf's stock count, with the codes to scan on another screen.

Time zones

A page may name the time zone its dates and times are in — a branch's, a clinic's — by its IANA name, and a date and time field its own: a flight's departure in its airport's. A date and time is kept as an instant, as always; it is shown and typed on the zone's clock wherever the person is, with the zone's short name beside its box where the browser's zone is another, and after it in words: 15 Oct 2026, 14:30 CEST, which a paste reads back. Today is the zone's day: a date's default "today", its earliest and latest counted from today, today(), a rule's past and future, and a booking's days. Without timeZone, the browser's own zone, as before.

{
  "timeZone": "Europe/Berlin",
  "fields": {
    "call_back": { "type": "datetime", "label": "Call back at" },
    "flight": { "type": "datetime", "label": "Departs", "timeZone": "Africa/Cairo" }
  }
}

On the night the clocks change, a time may not exist, or exist twice. Neither is ever moved in silence: there is no 02:30 on 29 Mar 2026 in Central European Time: the clocks go from 02:00 to 03:00; and 02:30 comes twice on 25 Oct 2026 in Central European Time, as the clocks go back; write 02:30 +02:00 or 02:30 +01:00 — the box keeps what was typed until an offset, or the zone's short name (02:30 CEST), says which. A box shows such a time with its zone's short name after it, so it reads back as the same instant. A zone the browser does not know is refused as the page is read. In the designer: the screen's Time zone, and a date and time's.

Booking slots

"widget": "slots" on a date and time books a time from those your app has free: a month whose days are shaded by how they are booked — free times left, fully booked, closed, a holiday by its name — beside the chosen day's free times as chips, all asked of the data source's slots, on the field's zone's clock. The arrows move across the days, the day's times following; Enter goes to its times, the arrows move among them, and Enter books one. A time someone else booked meanwhile is said when it is picked, and never booked — nor the time that slides under the pointer as the day's times close up: a double-click's second click books nothing, and what was said stays until another time is picked. Where the zone is not the browser's, a note under the picker names it all year (Times are Central European Time), and the booking chosen says its season's short name beside its times: 10:00 to 10:45 CET on 26 October, CEST the week before. Without slots in the data source, it is the date and time box. Open the test drive demo.

{ "type": "field", "id": "f-start", "field": "start", "widget": "slots",
  "options": { "schedule": "showroom", "length": 45, "between": 15, "endField": "stop", "dependsOn": ["car"] } }

schedule names what the app is asked for (the field's name unless said); length and between are the minutes a booking lasts and those kept free after it, unless the app says; endField, a date and time, takes the booking's end; dependsOn, the fields whose change asks again. In the designer: the kind Booking slots, with its Schedule, Minutes a booking lasts, Minutes kept free after one, Its end in, Asked again when, and Time zone.

A repeat rule

"widget": "repeat" on a char field says how often something comes back — a treatment course, a hearing, a check: every day, every week on the days ticked, every month on a day, on its last, or on the first Monday; every so many; never ending, until a day, or a number of times. Its value is an iCalendar rule (RFC 5545's RRULE), which a calendar or your server reads as it is, said in words under its boxes, at rest and in a list's column: Every 2 weeks on Tuesday and Thursday, 6 times. startField names the date it starts from: a new week's day and a month's day come from it. A rule the box cannot change (an hour, several days of a month) is kept as it is and said so. Its numbers and its end day are Fieldia's own boxes, with their input rules. In the designer: the kind Repeat rule.

{ "type": "field", "id": "f-sessions", "field": "sessions", "widget": "repeat", "options": { "startField": "first_session" } }
// "sessions": "FREQ=WEEKLY;INTERVAL=2;BYDAY=TU,TH;COUNT=6"

A week's opening hours

"widget": "hours" on a json field is a week's opening hours: a row a weekday, open or closed, its shifts from and to — Add a break splits the last at its middle — a shift taken away, and a day's hours copied to every day. Its value is what a booking schedule reads (the memory source's scheduleSlots reads it as hours): by ISO weekday, "1" Monday to "7" Sunday, each day's shifts in order; a day not named is closed. A shift that ends before it starts, or overlaps another, is said under its day and the record is not saved until it is put right. weekStart (1 to 7) is the day its week starts on; without it, the week's first day where the page is read (firstWeekday: an English page read in Cairo from Saturday, in London from Monday, in New York from Sunday), as a repeat's days are offered. At rest and in a list's column: Mon–Fri 09:00–13:00, 14:00–18:00 · Sat 10:00–14:00 · Sun closed. In the designer: the kind Opening hours.

{ "1": [["09:00", "13:00"], ["14:00", "18:00"]], "2": [["09:00", "18:00"]], "6": [["10:00", "14:00"]] }

Widget options

A node's options tune its widget. An option whose name ends in Field names another field of the page, and the format checks that it exists.

{
  "type": "field", "id": "f-spent", "field": "spent",
  "widget": "progressbar",
  "options": { "maxField": "budget" }
}
WidgetOptions
progressbarmax (the field's own, else 100), maxField, color (auto: red under 30 %, yellow under 70 %, green from there; or a fixed success, warning, danger, info), showPercent, editable (a box beside the bar)
labelprefix, suffix, or prefixField, suffixField to take them from another field: “240.0 m”, “370,000.00 EGP”
tags on a charsuggestions (a list of words), separator (","), max (at most so many). Kept as "oak, glass"
a char or text with a sizeA count of characters under the box, "12 / 100": a paste past it is kept whole, the count turns red, and the field says once, under its box, how much too long it is. A text takes rows (3) and grows as it is typed in unless autoGrow is false
an integer or floatprefix, suffix: a unit inside the box, before or after the number: "kg", "°C", "%"
radio, rating, scale, buttons on a boolean, slider, pictures to pickOne answer that need not be given shows Clear selection once picked; clear: false leaves it out, as an ERP's radios and priority stars have none — a rating's star picked, clicked again, then takes the answer away. A rating of one star (max 1, a priority) never shows it: its second click takes the star away
ratingicon: "heart", "thumb" or "number" instead of stars; startLabel, endLabel: words at each end
scalestartLabel, endLabel; nps: true colours a 0 to 10 scale as NPS, 0–6, 7–8 and 9–10 apart
sliderstep (1), startLabel, endLabel. Until it is moved it shows no value: a hollow ring at the start of a track with nothing filled, and Not answered beside it, never a knob halfway; a press or a key answers from there
time on a charmin, max ("09:00"), step in minutes
statusbarclickable, visibleStates. On a many2one its steps are the records the link may point to. durationsField: a json field holding the seconds spent in each step, by the step's value or stage's id, shown on each step (3d, 5h); fold: stages whose record is folded go under a ⋯ menu at the end, unless the record stands on one; saves: a click also saves the record, as Flectra's. Where its steps are wider than their room (a phone), the strip scrolls: the step the record is in is scrolled into view, at rest it starts on a step, never one cut mid-word, and each edge with more steps past it fades, with a sign that it scrolls
badge on a selectionThe chosen option's words in a pill, as Flectra's widget="badge"; tones: a tone for each value, { "high": "danger", "low": "success" }, muted for one given none
a monetary fieldThe currency's symbol inside the box, where the page's language writes it for that currency, as every total and cell of the page does (the field's money at moves it everywhere the field is written); pickCurrency: a currency box beside the amount
a date or datetimeweekNumbers: a calendar beside the date, with ISO week numbers, each row an ISO week from Monday (without them, each row starts on the week's first day where the page is read, firstWeekday); on a datetime, step in minutes
a binary or image fieldfiles: "list" (a file's default), "thumbnails" (an image's) or "cards": a picture over each file's name and size, the name in two lines at most, cut in the middle so its extension stays; filesSwitch: true puts List and Cards (or Thumbnails, when the page shows thumbnails) over the files, for the person filling the form to choose, kept with the page's preferences; camera: true has a phone offer its rear camera, "user" its front one
a char, text or html fieldrewrite: AI help by your app's own model — ["draft", "polish"] (or true): Draft writes it from the record, Polish makes the words there clearer, and { "how": "formal", "label": "More formal" } a tool of your own; each answer shown under the field to accept or reject, with Undo: see AI help. Hidden where the data source has no rewrite.; on a binary, record: "audio", "video" or both records a voice note or a short film on the page, each at most maxSeconds long
an html fieldtoolbar: false leaves the formatting toolbar off. The toolbar's Heading makes a heading in one press. As a work item's text: toolbar "focus" — no edge and no toolbar at rest, a light box when pointed at, the toolbar inside the box while worked in — at toolbarAt "top" or "bottom"; tools: which, in order, of bold, italic, underline, bulletList, numberList, highlight, colour, emoji, outdent, indent, strike, size, code, mention, reference, clearFormatting, image, link, unlink, taskList, heading, attach, table — those with no room go under “…”; what is pasted from Word, Excel, Google Docs or a page comes in plain in either editor — headings, marks, links, lists, tables and alignment kept; fonts, colours and widths left behind, though what is copied from a Fieldia editor keeps its own colours, highlights and sizes — and table puts one in at a size picked on a grid, adds and takes away rows and columns where the cursor is, sets its header row, and Tab goes from cell to cell; editor: "markdown" shows the text as it reads and edits it as Markdown in a card with a Preview, still stored as clean HTML — empty, with no placeholder, alone in a group whose heading holds its ✎, it takes no room until that ✎ starts it; edit: "button" reads the rich editor first too — its text formatted, links that open, pictures in place — with Edit (✎) in its group's heading; Edit, Enter or a press on its words opens the editor, Done or a press outside keeps what was typed, Escape puts it back, and empty it is its editor at rest; switchEditor: true offers the other editor, asking first when formatting would be lost; mention: { "model": "res.users" } and references: [{ "key": "#", "model": "work.item", "label": "Work item", "icon": "hash" }] find people after @ and records after their key, with your data source's search
links on a many2manyA work item's links: add: "menu" — Add link opens Existing item (a search) and New item (a new record in a dialog) — or "search"; addLabel: its words; help: words in a light box while none is linked, [words](https://…) as links, with helpIcon before them — white on a tile of helpTile's colour ("#d84a12"), as a tracker marks its code's links; emptyLink: a link in the empty box that finds an existing record. Each record linked opens from its name, and goes with its ×
a many2one or many2manycreate: false never offers to make a record from what was typed. With dialogs, both end their list with Search more… when it has no room, and open a linked record — a many2many from its tag — unless open is false, Flectra's no_open. avatar: true shows the record's picture before its name, or its initials (Flectra's avatar widgets) — and in the quiet look, while no one is picked, a person's outline before the node's placeholder, “No one selected”; on a many2one, details: true shows lines of the record under the link — an address, a tax number, as Flectra's show_address; on a many2many, colors: true draws each tag in its record's colour, 1 to 11 as Flectra numbers them (color_field). The picture, lines and colour come from the data source, with each record it finds or loads — see what a link shows
photos on an image field with multiplecover (true): the first photo is the cover, marked so; captions: true puts a caption under each photo; edit (true): Crop and turn on each photo; keepOriginal (true): the photo as it was kept beside one cropped; aspect: the shape every crop keeps, "4:3": a photo set
a char, text or many2one drawn as its box, a table's column, a one2many countedscan: true, or formats, by, part, fills, sound, and a table's field and count: a Scan button that reads a code with the camera — scanning a code
signature on a binarycolor ("#1b2a5c") and penWidth (3): the pen; the node's placeholder: words on the blank pad; footerLabel: words kept under it; upload: true lets a picture of a signature be uploaded. Undo takes the last stroke away; a typed name is kept as the value's text. signs: "form" or the fields by name, and signerField: a signature that signs the answers
address on a jsonparts: which, of street, line2, city, region, postcode, country (the first, third, fifth and sixth unless it says); requiredParts: those that must be filled, each asked for by name; country: the ISO code it starts on. The country is chosen from a list in the page's language and kept as its code, "EG"
a one2many as a tablemin: lines at least, a new table starting with them; max: at most; addLabel: the Add button's words, and addSectionLabel, addNoteLabel those of its section's and note's (the grid takes the three too); emptyLabel: a sentence while there is no line; confirmDelete: true asks before a line with something in it goes. A line moves by its grip, or by Alt+↑/↓ from inside it
duration on a floatHours as HH:MM, typed so or as 6.5: Flectra's float_time. suffix: words after it in its box, "hours"
percentage on a floatA fraction shown and typed as a per cent: 0.25 is 25 %, with the field's digits at the most
priorityStars over a selection, the first option none — "0"…"3" is three — or one over a boolean; the star picked, clicked again, takes them back to none
dot on a selectionA state's dot with a menu of the states. tones: a tone by value, { "blocked": "danger" } (else normal grey, blocked red, done green, then by place); colours: an exact colour by value, { "active": "#007acc" }, over its tone; label: true shows the state's words beside it; listDots: false lists the states as Fieldia's own list does, a tick by the one picked and no dots, at the start of the value's box and as wide — as a work tracker's State. A press on its words opens it too, and a field with a lead slot before its value (a work item's band) holds the dot there
a selection with no widgetlist: "own" draws it in Fieldia's own list in place of the browser's — its value as words on a button, and a list with a tick by the option picked, used with ↓↑, Home, End, Enter, Escape and by typing an option's first letters; Delete empties a choice that need not be made. As a work tracker's Priority and Severity
path on a many2oneA record of a tree — an area, an iteration — shown as its path, "Portal\Sprint 14", from the record's path (its names from the top down; see what a link shows). Its list, as wide as its box: Suggestions (the value and the person's latest picks of the model, kept in the viewer's preferences under recent:<model>), then the tree folded to the value's branch, each row's aside — an iteration's dates — at its end. Typing shows the records whose path has the words, flat. ↓↑ move, → opens a branch or goes into it, ← closes it or goes up (the other way round right to left), Enter picks, Escape puts back. separator ("\"), suggestions (5; 0 for none), tree (false leaves it out)
tree on a many2manySeveral records of a tree ticked — a checkbox tree. keeps: "all" every record ticked, "top" a whole branch as its own record, "leaves" the records with none under them; search: false leaves its search out
a many2many, or tags on a charadder: "button" adds tags from a button — its words the node's placeholder, else “Add Tags” — that turns into the tag box; Enter adds the tag typed (an existing one by its name, or a new one) and the button comes back, as it does on Escape and when the box is left. As a work tracker's Add Tag
daterange on a date or datetimeendField: the field of the last day. One box from → to, typed in or picked on a calendar
timerOn a float: the time logged, unit "minutes" when kept in minutes, and startField, a datetime it runs from while set. On a datetime: the time since it
colorOn an integer, Flectra's twelve tag colours from a palette (0 none); on a char, a colour as #rrggbb
copyThe value and a Copy button
pdf on a binary, embed on a charheight in pixels (480): the browser's own viewer of a PDF, or of the web page at the address, beside a link to open it in a tab — another site's page in its own origin, a page of yours in none (it never reaches the form's page), so its scripts need Access-Control-Allow-Origin from your server, as GitHub Pages and most CDNs send
distribution on a jsonmodel: the accounts' ("account.analytic.account")
tax-totals on a jsoncurrencyField or currency; editable: true lets the tax amounts be typed while the field is not read-only
payments on a jsoncurrencyField, dueField (the amount still due), model of a payment's page ("account.payment")
a properties fieldcolumns: 2 lays them side by side; add: true, with definitionsFrom, offers Add a property in place
cards on a one2manymin, max, itemLabel (a card's title), addLabel. Each card moves up and down by its arrows, and is copied, answers and all, right after itself

Files and photos

Where the data source stores files (its upload), each file goes to your store as soon as it is picked: a field of files or pictures shows it on its way — its picture, a bar that fills, where it is in words, × to cancel it, and Retry when it did not get there — and then holds its link alone. Save waits for files still going, saying so. See files stored as they are picked.

A field's shrink makes its photos smaller before they are kept: JPEG, PNG and WebP pictures (and HEIC, where the browser reads it) whose longest side is over maxSide pixels are drawn again that size, standing as they were taken (their EXIF turn applied), and written at quality. A photo already that small is kept as it is, none is made larger, and a smaller one is taken only when it is smaller in bytes. A field's maxSize is checked once a photo is made smaller, so a 12 MB photo from a phone fits a field of 5 MB.

"photos": {
  "type": "image",
  "label": "Photos",
  "multiple": true,
  "maxFiles": 20,
  "maxSize": 5242880,
  "shrink": { "maxSide": 1600, "quality": 0.82 }
}

shrinkPhoto(file, { maxSide, quality }) from @fieldia/widgets does the same for your own code.

A photo set

A listing's photos, a product's gallery, a clinic's before and after: a picture field of several photos drawn as "widget": "photos" shows them as tiles in the order a person puts them. The first is the cover — marked so, and what a list's card and a map's pin show — and each photo is cropped and turned in place, with a caption under it where the page asks.

{
  "type": "field",
  "id": "f-photos",
  "field": "photos",
  "widget": "photos",
  "options": { "captions": true, "aspect": "4:3", "camera": true }
}

Everything is kept in the field's value, so any data source that keeps a file value keeps it: the photos in order, each one's caption, and a cropped one's original and edit — { "turn": 90, "crop": { "x", "y", "width", "height" } }, fractions of the original as turned. A photo set comes in a part of its own, fieldia.photos.js, loaded only for a page that has one. In the designer, it is the Photo set kind, its settings on its card and in the panel.

Not done yet, for 0.29: a photo set inside a table line's cell is untested; pictures a second crop or Put back the original replaced stay in your store — the form never deletes a stored file, so they are your store's to clean; a photo stored on another site is cropped only where that store lets the page read it (CORS), else the dialog says it cannot be read.

Films and sounds

A film or a sound in a file field plays in the browser's own player — a property's video tour, a procedure's clip, a voice note from a site visit. Among the files, a film shows its poster frame under a play mark; opened, it plays in the dialog's player, starting from that frame. A sound in a list plays where it is, its player under its name; on a card or a thumbnail it opens and plays under its name. A file's kind is its media type (video/…, audio/…), else, where none is known, its extension (mp4, webm, mov; mp3, m4a, wav, ogg, opus). One the browser cannot play says so in the player's place, with Download over it.

The poster frame is the app's own where the file has one — a picture its store made, as poster in the file's value — else the film's frame half a second in, drawn by the browser from the film itself. Fieldia reads poster; it never writes it.

{ "name": "tour.mp4", "type": "video/mp4", "size": 4182016, "url": "https://files.example/tour.mp4", "poster": "https://files.example/tour.jpg" }

A voice note or a short film, recorded on the page

A file field whose node says record offers Record a voice note or Record a video beside its picker — on a computer and on an iPhone alike, where a file input alone offers no recorder. The recorder opens over the form and the browser asks for the microphone (and the camera for a film, the rear one on a phone); then Start recording, the time against the limit, and Stop. Stopped, the recording plays back in the browser's own player, with Use this recording and Record again; used, it is the field's as a file picked is — stored as it is made where the data source has upload, else inside the record — and plays in place there.

"voice_notes": { "type": "binary", "label": "Voice notes", "multiple": true, "accept": ["audio/*"], "maxSize": 10485760 }

{ "type": "field", "id": "f-voice", "field": "voice_notes", "options": { "record": "audio", "maxSeconds": 120 } }

A value shown as a QR code or a barcode

A ticket at the door, "open it on your phone", an asset's label: "widget": "qrcode" on a char or text field shows its value as a QR code, "widget": "barcode" on a char or integer field as a Code 128 barcode — drawn on the page from the record's own value, so no picture is made on a server, and as sharp on paper as on the screen. Editable, the field's box is over the code, which follows what is typed; read-only, the code alone, its words under it where showValue says.

{ "type": "field", "id": "f-link", "field": "ticket_link", "widget": "qrcode", "options": { "level": "Q", "size": 200 } }
{ "type": "field", "id": "f-number", "field": "reference", "widget": "barcode" }

The legal codes on an invoice or a receipt (ZATCA's, an e-receipt's) belong on the printed document, which your report engine makes; this is for the screen.

Pins on a picture

A clinic's face chart, a floor plan's snags, a car's damage at its return: "widget": "pins" on a json field puts pins with notes on a picture. A click or a tap puts a pin there and goes to its note; a pin is dragged to move it. By the keyboard, Tab reaches the picture, the arrow keys move a cross over it (Shift: further) and Enter puts a pin under it; on a pin, the arrow keys move it, Delete takes it away and Enter goes to its note. Under the picture the pins are a numbered list — each one's place in words, its note's box and Remove — which is what a screen reader reads, each pin a button named "Pin 2, top left, 18% across, 22% down: Botox, 4 units".

"injections": { "type": "json", "label": "Injection points" }

{ "type": "field", "id": "f-injections", "field": "injections", "widget": "pins",
  "options": { "image": "/charts/face.svg", "alt": "Face, from the front", "noteLabel": "Product and units", "maxPins": 30 } }

The value is the pins, each where it is on the picture as a share of its width and height from its top left corner, so they stand where they were put at any size the picture is drawn:

[{ "x": 0.4, "y": 0.29, "note": "Botox, 4 units" }, { "x": 0.5, "y": 0.68, "note": "Filler, 0.5 ml" }]

A signature that signs the answers

A consent, an engagement letter, a reservation contract: a signature's picture alone is weak evidence in a dispute. A signature whose node says signs — "form", every answer shown, or the fields by name — keeps beside its picture who signed, when, and a fingerprint (SHA-256) of the answers it signed, and locks those answers while it is kept. signerField names the field holding the signer's name; left out, the name typed on the pad, else the person the app says is using the form.

{
  "type": "field",
  "id": "f-signature",
  "field": "signature",
  "widget": "signature",
  "options": {
    "signs": ["patient", "treatment", "areas", "risks_read"],
    "signerField": "patient",
    "footerLabel": "I agree to the treatment described above."
  }
}

The fingerprint is the SHA-256 of a canonical text your server can write again in any language: the JSON { "answers", "at", "by", "field", "format", "page" } as RFC 8785 writes it — no spaces, keys in order — each answer as the person saw it, written so a store that hands it back another way reads the same (a link its record's id, a file its name, size and kind, nothing null). The rules are in @fieldia/core's README; the evidence part — loaded only for a signature that signs answers, never for uploads or a plain signature — has them as functions:

import { evidencePart } from '@fieldia/widgets';

const { answersMatch, signatureText, sha256Hex } = await evidencePart.load();
await answersMatch(record.signature.signed, page, 'signature', record); // true while no signed answer changed

In the designer, a signature's settings say what it Signs — nothing, every answer on the page, or the answers chosen — and the Signer's name. Two people signing in turn is your app's to order (a flow's): each signature signs its answers.

Filled in by the browser, and a phone's keyboard

A field node's autocomplete says what the browser may fill its box in with, from what the person saved: a purpose from the HTML standard's list — name, given-name, family-name, email, tel, organization, street-address, postal-code, country, bday, one-time-code, cc-number… — with shipping, billing or section-… before it, and home, work or mobile before a phone or an email; or off, so the browser offers nothing. Its inputmode picks the keyboard a phone shows: numeric, decimal, tel, email, url, search or text. The page's checks refuse a purpose the standard does not list, in its words.

{ "type": "field", "id": "f-name", "field": "full_name", "autocomplete": "name" },
{ "type": "field", "id": "f-phone", "field": "phone", "widget": "phone", "autocomplete": "mobile tel" },
{ "type": "field", "id": "f-code", "field": "code", "autocomplete": "one-time-code" },
{ "type": "field", "id": "f-ship", "field": "ship_to", "widget": "address", "autocomplete": "shipping" }

Each kind has its own unless the node says: an email box email and its keyboard, a phone tel, a url url, a password new-password — a password being set, never the one the person signs in with filled into a record's field — a number its digits (a decimal mark where it has places, the full keyboard where it may be below 0), and an address in parts each part its own (address-line1, address-level2, postal-code, country): its node names only whose address it is, "shipping", or "off". A line of words offers nothing unless its node names a purpose, and then shows that purpose's keyboard (digits for one-time-code). A choice drawn as a list, or as a box to type in for a long one, takes a purpose too, such as country-name. A link to a record keeps the browser out: it looks records up by their names.

What the browser fills in is the person's own, read as typed: a box filled from a pick in another one is read at once, as one left, and says its problem there; in the box picked in, what the box would refuse is held, said, and taken as it is left, never lost. It is a change of theirs like any other: Discard and a way out ask about it, and Save sends it. In the designer, a field's Content tab sets both: Filled in by the browser as and Keyboard on a phone.

Numbers in the reader's language

Numbers are written grouped, with the field's digits (two for money and decimals by default), the way readers of the page's locale write them: 1,850,000.00 in English, 1.850.000,00 in German, 1 850 000,00 in French, in Latin digits in Arabic. What is typed is read the same way, Arabic-Indic digits included.

Links to other records

many2one, many2many and reference find records through your data source's search. A filter limits what can be picked, and valueFrom follows another field — here, the regions of the chosen country:

"state_id": {
  "type": "many2one",
  "label": "Region",
  "relation": "country.region",
  "filter": [{ "field": "country_id", "op": "=", "valueFrom": "country_id" }]
}

A filter's items all hold together; a group of any holds when one of its items does, and all groups nest inside it. Besides = != < > <= >= in not in, a condition can find text with like (as typed), ilike, startswith or endswith (whatever the case), ask whether a field is set or notset, or take a value between two. contains holds when a record's many2many holds the value, or one of a list — Flectra's = and in on a many2many, such as a stage's projects — and not contains when it holds none. =? is = while its value is set and is left out while it is empty, as Flectra's: "this company, if the record has one". A record's own id can be tested against a list the form holds: { "field": "id", "op": "in", "valueFrom": "available_journal_ids" }.

"approver_id": {
  "type": "many2one",
  "label": "Signs off the design",
  "relation": "employee",
  "filter": [
    { "field": "active", "op": "set" },
    { "any": [
      { "field": "job", "op": "startswith", "value": "Head of" },
      { "field": "job", "op": "endswith", "value": "manager" }
    ] }
  ]
}

When nothing found has the name that was typed, the list ends with Create “…”: it makes the record through the data source's create and links to it. It is offered only when the data source can create, and never on a node with "create": false.

Records in dialogs

Give the viewer the pages that edit your related records, keyed by model, and a link field opens them in a dialog without leaving the page:

mountViewer(host, {
  page: projectPage,
  dataSource,
  pages: { partner: customerPage },   // or (request) => page | null: request.model for a link
});

In React pass pages={…}, in Vue :pages="…", in Angular [pages]="…". The same option gives a saved form placed in a page by its id (request.id, request.version); the older relatedPages, by model only, is still read. A link to one of those models then offers:

Every link, with or without a related page, ends its list with Search more… when more records match than the list shows (eight). It opens every match in a dialog with its own search box; a click or Enter picks one.

A dialog takes the focus to its first field, keeps Tab inside, and gives the focus back where it came from when it closes. A link's or a choice's list drops open for a person — a click or a tap on its box, a word typed, Alt+Down or the arrows — never for the focus alone: a dialog's first field, a refused save going to the field to fix, or Tab keeps its list closed over the fields under it. Escape closes a list open inside it first, then the dialog — asking “Discard your changes?” first when something was typed, the focus on Cancel so Enter keeps it. The page's own Save and Discard give way to the dialog's Discard and Save & Close.

Your own dialogs

import { openFormDialog, openSearchDialog } from '@fieldia/viewer';

const { saved, recordId, values } = await openFormDialog({
  page: taskPage, dataSource, recordId: null,
  title: 'New task',
  size: 'medium',          // 'small' | 'medium' | 'large' | 'full'
});

// "values" mode only checks the form and hands its values back: nothing is saved.
const line = await openFormDialog({ page: linePage, values, title: 'Line', mode: 'values' });

const picked = await openSearchDialog({ title: 'Customer', search: (query, limit) => mySearch(query, limit) });

openFormDialog takes every option mountViewer does. In "values" mode a recompute(values) option recalculates the values as they change, and the dialog shows what comes back.

Side panels

openFormPanel opens a page in a panel instead: full height at the inline-end edge (the left, right to left) unless it names another side, the page behind dimmed but still in sight, and the whole screen on a phone. It takes the dialog's options, with side, width and height in place of size, and hands back the same result.

import { openFormPanel } from '@fieldia/viewer';

const { saved, recordId, values } = await openFormPanel({
  page: callPage, dataSource, recordId: null,
  title: 'Log a call',
  width: 'medium',          // 'narrow' | 'medium' | 'wide': about 420, 560 or 720 pixels
  look: page.look,          // the opener's accent, scheme, corners and font
});

// From another edge: the whole width along the top, 40 in a hundred of the screen tall.
await openFormPanel({ page: callPage, dataSource, title: 'Log a call', side: 'top', height: 'short' });

side is the edge it comes from: 'end' (the default: the end of the line, the right, or the left right to left) or 'start', as the page reads; or 'left', 'right', 'top' or 'bottom' of the screen, whatever the page's direction. At the left or right, width is how deep it is; at the top or bottom it runs the whole width, and height says how tall: 'short', 'medium' (the default) or 'tall', about 40, 60 or 85 in a hundred of the screen. On a phone every side fills the screen, the top sliding down from above and the rest up from below. A page's step opens one with "as": "panel" and the same "side".

Its foot has Discard and Save & Close, or Discard and Done in "values" mode. Escape and × ask “Discard your changes?” first when something was changed; Discard does not ask. A dialog opened from inside it, such as a link's Create and edit…, sits above it; a panel opened from it stacks over it, the older one stepped back from its own edge; each gives the focus back as it closes. It slides in from its edge only when the reader's system welcomes motion. Try it on Every field in JavaScript: “Log a call in a side panel”, over the form, from the right, left, top or bottom.

Tables of lines

A one2many declares the fields of each line; the node's columns says which show as columns. Lines are added, edited and removed in place, and saved as create, update and delete operations — see what a save sends.

"child_ids": {
  "type": "one2many",
  "label": "Contacts",
  "relation": "partner",
  "fields": {
    "name":  { "type": "char", "label": "Name", "required": true },
    "email": { "type": "char", "label": "Email" }
  }
}

Sections and notes

Lines can be headings and remarks between the items, the way a quotation is laid out. lineKinds names the line field that says what a line is and the field that holds its text. A section or note runs across the row, and it is never asked for what an item needs, such as a product.

"line_ids": {
  "type": "one2many",
  "label": "Order lines",
  "relation": "sale.order.line",
  "lineKinds": { "field": "display_type", "text": "name", "section": "line_section", "note": "line_note" },
  "sequenceField": "sequence",
  "fields": { ... }
}

section and note are the values that mark each kind; they default to "section" and "note". With a sequenceField (an integer line field) lines can be moved, and only the lines that moved are numbered again. Neither field shows as a column.

Rows pasted from a spreadsheet

Rows copied from Excel, Google Sheets, LibreOffice or Numbers and pasted in a cell of a table of lines — a dropdown's too, with Ctrl or ⌘ and V — or on a cell of the grid, chosen or opened for typing by a click, in Safari too — go each on its own line, across the columns from that cell: each cell read as its column reads what is typed — a number in any script with the page's marks, an amount in its line's currency, a day in the page's order, a choice by its label, a product or any link by its exact name, looked up through your data source's search as typing it is — a cell a spreadsheet quoted (a line break or a tab inside it) read as one. Rows past the last line add lines, as many as the table's max lets it have. A row whose name reads as no record — nothing, or more than one, called so — is not pasted at all: never its description and price on another product's line. A cell that cannot take what was pasted keeps what it holds, and one note under the table says what went in and what did not, with why: Pasted into 7 cells. 2 lines added. Not pasted: the row starting “Laser printer”, none of it (Product: nothing is called “Laser printer”); Unit price, line 3 (Unit price: “abc” is not a number). One value pasted is the box's own paste, and a paragraph's lines go into the paragraph.

Choices that follow another column

A line's choice may take its options from one of your app's lists rather than the page — an agent's tools from the connection on that line, a size from the product chosen beside it. optionsFrom names the list and the columns it changes with; parent. and a field, the record the line is on. Each line's choices are asked through your data source's options with that line's values (the record as parent), and lines whose columns hold the same values share one answer. When a line's connection changes, its tools are asked again; a tool the new connection does not offer is taken out and said under its cell — Send an email is no longer offered, so it was taken out — in the grid too, and aloud there — until a tool is chosen or the connection that offers it is back; one it offers too stays. A record that comes in with a tool its choices no longer offer keeps it, said, until the person chooses: Save says why. The plain table, the grid, cards and a line's own form alike; a block pasted reads each tool among its own line's choices, its connection read first; Import reads a choice that follows another field by each row's own values. A page's own choice from a list — a city by its country — is taken out and said the same way when the field it changes with changes. In the designer, a table's column is a Choice, its options written under its row or one of your app's lists, ticking the line's columns and the record's fields it changes with.

"tool_ids": {
  "type": "one2many",
  "label": "Tools",
  "relation": "ai.agent.tool",
  "fields": {
    "connection_id": { "type": "many2one", "label": "Connection", "relation": "ai.connection" },
    "tool": { "type": "selection", "label": "Tool", "options": [], "optionsFrom": { "list": "connection_tools", "dependsOn": ["connection_id"] } }
  }
}

Your options({ list, values, parent }) is asked { list: "connection_tools", values: { connection_id: { id: 2, label: "Slack" }, … }, parent: { name: "Sales inbox helper", … } }. Try an AI agent's tools.

On the node

The node that shows the table can add up number columns in a row under the lines, and let people hide or show some columns:

{
  "type": "field", "id": "f-lines", "field": "line_ids",
  "widget": "grid",
  "totals": ["qty", "subtotal"],
  "optionalColumns": { "discount": "show", "lead_days": "hide" }
}

"hide" starts a column hidden. Sections and notes stay out of the totals.

order puts the lines in an order of their own fields as they load, as Flectra's list default_order: [{ "field": "is_done" }, { "field": "manual_consumption", "desc": true }, { "field": "sequence" }] — by the first field, then the next, desc turning one round; empty values and false first, a link by its name. Both the plain table and the grid show that order. A line a person drags (with a sequenceField) or adds stays where it is until the lines load again — opening the record, or a save bringing them back. In the designer: Table, Lines in order of — is_done, manual_consumption desc, sequence.

The grid

For orders, invoices and timesheets, @fieldia/grid shows a table of lines as a spreadsheet on AG Grid, with Fieldia's own fields in the cells. It is a separate package, so simple forms never load it:

npm install @fieldia/grid ag-grid-community
import { gridWidgets } from '@fieldia/grid';

mountViewer(host, { page, dataSource, widgets: gridWidgets });
// a one2many node with "widget": "grid" now shows the grid

In React pass widgets={gridWidgets}, in Vue :widgets="gridWidgets", in Angular [widgets]="gridWidgets". A node without "widget": "grid" keeps the plain table.

A table's own rules

Each line of a table can be read on its own, as Flectra's editable lists do. Under cells, a column's invisible, readonly and required are conditions on its line — its fields, its own id (empty until the line is saved, so "readonly": "id" locks a saved line), with the record it is on as parent — and its hidden a condition on the record that hides the whole column, as column_invisible does. A cell its line hides stays, blank, so the column still lines up; one its line requires stops a save until it has a value.

{
  "type": "field", "id": "moves", "field": "move_ids", "widget": "grid",
  "cells": {
    "product_id": { "readonly": "parent.state != 'draft'" },
    "quantity": {
      "hidden": "state == 'draft'",
      "tones": [{ "tone": "danger", "when": "quantity > product_uom_qty" }],
      "bold": "quantity > 0"
    },
    "lot_id": { "invisible": "not has_tracking", "required": "has_tracking and parent.state == 'assigned'" },
    "state": { "badge": true, "tones": [{ "tone": "success", "when": "state == 'done'" }] }
  },
  "rowTones": [{ "tone": "muted", "when": "scrapped" }],
  "rowButtons": [
    { "type": "button", "id": "serials", "label": "Assign serial numbers", "icon": "list",
      "invisible": "not has_tracking", "action": "action_assign_serial" }
  ]
}

Both the plain table and the grid draw them; the form reads them, so your own widget can too, with form.lineState(node, key) and form.columnHidden(node, column).

How an amount is written where it is read — a list's cell, a field shown as words, a map's card and pins — is its field's money: currency "code" writes EGP for E£; at "before" or "after" puts it there instead of where the page's language does; short writes 13.9M, 13.9 مليون in Arabic; home, a currency's code, leaves that one unsaid and names any other; and per says what the amount is for while a condition holds on the record, the first that holds — [{ "period": "month", "when": "offer == 'rent'" }] writes 25,000 EGP/month, in each of Fieldia's languages (day, night, week, month, year). Digits stay Latin, as everywhere in Fieldia, and each amount keeps its own direction: 1,610,000 EGP reads the same on an Arabic page, and a symbol such as E£ is never turned round. Without money, an amount is written as it always was. The amount's own box follows its currency and at. In the designer: an amount's Currency as, Currency goes and Short.

"price": {
  "type": "monetary", "label": "Price", "currencyField": "currency", "digits": [16, 0],
  "money": { "currency": "code", "at": "after", "per": [{ "period": "month", "when": "offer == 'rent'" }] }
}

A line's money can be in the record's currency, as Flectra's related currency_id: "currencyField": "parent.currency_id" on a line's monetary field. Its cells, the total under them and the line's dialog follow the record's currency as it changes.

An answer rule on a table, { "distinct": "partner_id" }, refuses two lines with one value in that column — a split's payers, each once — as a model's constraint would: "Payer: Mona Adel is on more than one line of Split". Empty cells, sections and notes are left out.

A table's buttons

Besides a line's own rowButtons, a table takes buttons for the lines chosen in it and buttons beside Add a line:

{
  "type": "field", "id": "workorders", "field": "workorder_ids", "widget": "grid",
  "selectedButtons": [
    { "type": "button", "id": "wo-start", "label": "Start", "action": "button_start", "invisible": "state == 'done'" },
    { "type": "button", "id": "wo-done", "label": "Done", "action": "button_finish", "confirm": "Mark the chosen work orders done?" }
  ],
  "controlButtons": [{ "type": "button", "id": "catalog", "label": "Catalog", "icon": "list", "action": "action_add_from_catalog" }],
  "options": { "copy": true }
}

Lines with pages of their own

"compliance_ids": {
  "type": "many2many", "label": "Compliance", "relation": "legal.compliance",
  "fields": {
    "name": { "type": "char", "label": "Requirement" },
    "state": { "type": "selection", "label": "Status", "options": [{ "value": "open", "label": "Open" }, { "value": "met", "label": "Met" }] }
  }
}
…
{ "type": "field", "id": "compliance", "field": "compliance_ids", "columns": ["name", "state"] }

On a phone

A field's value in a tone

A field outside a table takes tones and bold too, read on the record — Flectra's decoration-danger on a field: a deadline red once it has passed, hours available red below what is needed. "widget": "badge" draws a choice, text or link as a pill in its tone, never edited; in a table, a cell's "badge": true.

{ "type": "field", "id": "deadline", "field": "date_deadline",
  "tones": [{ "tone": "danger", "when": "date_deadline and date_deadline < today() and state != 'done'" }] }

{ "type": "field", "id": "status", "field": "deadline_status", "widget": "badge",
  "tones": [{ "tone": "danger", "when": "deadline_status == 'late'" }, { "tone": "success", "when": "deadline_status == 'ok'" }] }

form.fieldTone(node) says the tone and bold now.

Business widgets

The widgets an ERP's screens lean on, each the Flectra widget it stands for. Open the business widgets demo to use them all on one task.

"title": {
  "field": "name",
  "before": [{ "type": "field", "id": "f-priority", "field": "priority", "widget": "priority" }],
  "after": [{ "type": "field", "id": "f-state", "field": "kanban_state", "widget": "dot" }]
}

{ "type": "field", "id": "f-dates", "field": "request_date_from", "widget": "daterange", "options": { "endField": "request_date_to" } }
{ "type": "field", "id": "f-duration", "field": "duration", "widget": "timer", "options": { "startField": "timer_start", "unit": "minutes" } }

In a table, a column's cells take a widget of their own, and its options — Flectra's widget= on a list's column: progressbar, priority, dot, color and timer are used in the cell itself, in the plain table and the grid; duration and percentage are typed in the cell as in their field, and say their totals the same way.

"cells": {
  "priority": { "widget": "priority" },
  "allocated_hours": { "widget": "duration" },
  "progress": { "widget": "progressbar", "options": { "maxField": "allocated_hours" } }
}

Properties defined by a linked record. A properties field with definitionsFrom takes its definitions from the app — those its link's record keeps, as a task's properties are its project's — through the data source's definitions, again as the link changes. With "add": true a property is added in place, its name and its kind, and handed to saveDefinitions.

"task_properties": { "type": "properties", "label": "Properties", "definitionsFrom": { "list": "task_properties", "dependsOn": ["project_id"] } }

{ "type": "field", "id": "f-props", "field": "task_properties", "options": { "columns": 2, "add": true } }

Code in a code editor

@fieldia/code shows a json, text or char field in CodeMirror, coloured in the language its node names: 44 of them, from Python, SQL and TypeScript to YAML, shell and C#, each loaded only when a field uses it. Tab still moves to the next field (Ctrl+] and Ctrl+[ indent), code reads left to right on an Arabic page, and the colours follow the page's light or dark scheme. In a json field, valid JSON reaches the form as it is typed; text that is not valid is said so, and the last good value stays. Try it.

import { codeWidgets } from '@fieldia/code';

mountViewer(host, { page, dataSource, widgets: { ...gridWidgets, ...codeWidgets } });
// { "widget": "code" } on a json field, or with { "options": { "language": "python" } } on a text field

VS Code's editor. @fieldia/monaco draws the same fields in Monaco, VS Code's own editor: find and replace, folding, several cursors, VS Code's keys, in the form's theme. It is large (about 800 KB gzipped), so it loads only when a page has such a field, and the field is a plain text box until then. Language services (checking JSON or TypeScript as it is typed) run when the app hands it their workers.

One line. In either editor a char field is one line of code, such as a condition, as tall as a text box and drawn as one: Enter adds no line (it moves on to the next field where the page asks, with keys: { enterMovesToNext: true }), pasted lines join into one, Tab moves on, and the node's placeholder shows while it is empty.

import { monacoWidgets, createMonacoWidgets } from '@fieldia/monaco';

mountViewer(host, { page, dataSource, widgets: monacoWidgets });
// { "widget": "monaco", "options": { "language": "typescript" } } on a text or char field
// with workers: createMonacoWidgets({ getWorker: (_id, label) => new Worker(…), services: ['json'] })

Places and areas on a map

@fieldia/map adds a place and an area as fields, on the map provider you choose: Azure Maps, Google, Mapbox, your own map images, or OpenStreetMap's for a demo. A place is set by a press on the map, a dragged pin, an address found, typed coordinates or “My location”, and kept as a GeoJSON Point (or in two number fields, as Odoo keeps a partner's place). An area is a polygon, a box or a circle, drawn by mouse, finger or keyboard, reshaped by its grips, and kept as a GeoJSON Feature. Leaflet draws them, loaded only when a map is shown. An address with suggestions is a text field and no map: the provider suggests addresses as people type, what is typed stays when none is picked, and one picked can fill a place field and an address's parts (a json.address field). Try a place · try an area · try an address. A list's records can be on a map too: see lists on a map.

import { mapWidgets, azureMaps } from '@fieldia/map';

mountViewer(host, { page, dataSource, widgets: mapWidgets({
  provider: azureMaps({ token: () => fetch('/maps/token').then((r) => r.text()) }),
}) });
// { "widget": "place", "options": { "addressField": "street" } } on a json field
// { "widget": "area", "options": { "shapes": ["polygon", "box"] } } on a json field
// { "widget": "address-search", "options": { "placeField": "spot", "partsField": "parts", "countries": ["EG"] } } on a char field

Your own widget

A widget is a function that gets the field and returns an element, an update that receives the current value, and a focus. Register it under a type, or under type.widget to offer it as a choice:

import type { WidgetFactory } from '@fieldia/widgets';

const colour: WidgetFactory = ({ form, name, id, document }) => {
  const input = document.createElement('input');
  input.type = 'color';
  input.id = id;
  input.addEventListener('input', () => form.setValue(name, input.value));
  return {
    element: input,
    focus: () => input.focus(),
    update: ({ value, readonly }) => {
      input.value = String(value ?? '#000000');
      input.disabled = readonly;
    },
  };
};

mountViewer(host, { page, dataSource, widgets: { 'char.colour': colour } });
// a node with "widget": "colour" on a char field now uses it

In React, Vue and Angular a custom field can be a component of that framework instead — pass it as fieldTypes.

A part that fails

Your own parts can have bugs. A widget — yours, or one of Fieldia's given what it cannot draw — a slot's content, a map, or any other part of the page that throws as it is drawn or brought up to date shows a small box in its place, "This field could not be shown: Price" or "This part could not be shown", in the page's language and as a status a screen reader says. The rest of the form goes on working, and saving: the field keeps the value it had. The error goes to the console and to onError, with where it happened:

mountViewer(host, {
  page,
  dataSource,
  widgets: { 'monetary.tag': yourPriceTag },
  slots: { planner: yourPlanner },
  onError(error, where) {
    // where: { stage: 'update', part: 'field', field: 'price', node: 'f-price', widget: 'monetary.tag' }
    //     or { stage: 'draw', part: 'slot', name: 'planner', node: 'n-planner' }
    yourErrorReporting.capture(error, { tags: where });
  },
});

stage is what was being done: 'draw', 'update', 'focus' or 'remove'. part is 'field' for a field's widget (a table's cell too), else the part's type: 'slot', 'map', 'section' and so on. A part that failed is left alone after: it is told once. A handler that throws is told to the console, and goes no further.

In React and Vue, a field's or a slot's component that throws as it renders is caught the same way — without it, React takes down everything under the nearest error boundary, the form with it. Pass onError as a prop (@error in a Vue template). In Angular, listen to (partError): { error, where }. A widget of your own that learns of its own failure later, where nothing would catch it, calls context.fail(error): its field shows the box, as if it had thrown. Demo: a part that fails.

A field that fails on a change the person is making in it — the key that made 450 into 4501 — keeps nothing it never showed: the field goes back to the value it last showed, and its box says so, naming the value as the field shows it, "Your change was not kept: it is back to EGP 450.00.", so nothing half-typed is saved unseen. The focus that was in the field goes to the box, which says what failed; Tab goes on from there, and the box is in the order the field had. A value the field was handed — the record's, a step's, the app's — is kept as it is. A widget that draws after its update returns, as a framework's component does, says what it drew with context.drew(value), so the value it goes back to is one the person saw; the React and Vue bindings do this for you.