Code#
Code holds source text (a snippet of HTML or CSS, a query, a
configuration), code in the descriptor. It keeps the text in a string
property (a TEXT column, as a Text field would) and edits it in a
code editor that highlights its language():
Code::make('routingRules', 'Routing rules')->language('yaml')->rows(8),
Option |
Effect |
|---|---|
|
The highlighting: |
|
Turns the gutter’s line numbers off, for a short snippet. They are on by default. |
|
How many lines the editor shows before it scrolls, 2 to 40 (10 by default). |
None of them changes what is stored: on the wire the value is the text
as typed, whitespace included, and the server validates it as text
(required(), max(), rule()), never as the language. It sorts,
filters and searches as a text column does, and is not edited inline. A
list shows its first line in monospace, shortened; the record page shows
it highlighted in a read-only editor.
The editor follows the light and dark theme, is read-only for a
readonly() field and in a disabled form, and shows a violation on its
frame like any input. Tab moves to the next field, as it does everywhere
else in the form, and the editor is labelled by the field’s label. Code
reads left to right in a right-to-left layout too. The editor and each
language’s highlighting load only when a form or a record first shows
one, so pages without a code or JSON field never download them.
It takes the common modifiers too.