Skip to content

Editors

Editors are the input widgets used in Serenity forms. They are created by the PropertyGrid based on the editor type specified in the form metadata (via editor attributes on the server side), and they implement standard value interfaces so the form can read and write their values.

The EditorWidget Base

Most editors derive from EditorWidget, which extends Widget and adds editor-specific props and read-only handling:

type EditorProps<T> = WidgetProps<T> & {
    initialValue?: any;
    maxLength?: number;
    name?: string;
    placeholder?: string;
    required?: boolean;
    readOnly?: boolean;
}

EditorWidget provides a readOnly property that sets/gets the read-only state of the editor's element.

Value Interfaces

Editors implement value interfaces that let the form (and other code) interact with them generically:

Interface Purpose
IStringValue get_value() / set_value() for string editors.
IDoubleValue get_value() / set_value() for numeric editors.
IBooleanValue get_value() / set_value() for boolean editors.
IGetEditValue getEditValue(property, target) — writes the editor value into a target object.
ISetEditValue setEditValue(source, property) — populates the editor from a source object.
IReadOnly Marks a widget as supporting read-only state.
IValidateRequired Marks an editor that participates in required validation.

The PropertyGrid uses these interfaces to load entity values into editors and to collect edited values back into the entity.

Editors by Task

Text Editors

Editor Description
StringEditor Single-line text input.
TextAreaEditor Multi-line text area.
EmailEditor Email input with validation.
EmailAddressEditor Email address input.
PasswordEditor Password input.
URLEditor URL input.
MaskedEditor Masked input.

Numeric Editors

Editor Description
IntegerEditor Integer input.
Int64Editor Int64/long input, preserving values beyond Number.MAX_SAFE_INTEGER as bigint or strings.
DecimalEditor Decimal input.
AutoNumeric Numeric input with formatting.

Date and Time Editors

Editor Description
DateEditor Date picker.
DateTimeEditor Date-time picker.
DateYearEditor Year picker.
TimeEditor Time picker.

Selection Editors

Editor Description
SelectEditor Dropdown from a static list; setItems(items) replaces the items at runtime, keeping the value only while it is one of the new items.
EnumEditor Dropdown from an enum or a StringEnum; the flags option stores the OR of the selected members.
ComboboxEditor Combobox with search, the base of the select, enum, lookup and service lookup editors.
RadioButtonEditor Radio button group.
BooleanEditor Checkbox; the labelPosition option places the caption after it (start, end, endAligned).
CheckTreeEditor Checkbox tree.

Combobox Options

The combobox based editors (select, enum, lookup and service lookup) share the options of ComboboxCommonOptions:

Option Meaning
checkList Shows a multiple editor as a checklist instead of one choice per selected item: the results get check boxes, the first item selects all the shown results (or clears them, see selectAll), and the selection is a summary (maxSummaryItems). Implies multiple, see Forms & Editors.
placeholderIcon The icon shown when nothing is selected.
textKeyField The field of an item that holds its local text key (or "text" when the text is its key), so the editor localizes it.
cssClassField The field of an item that holds its CSS class, e.g. text-danger.
dropdownAutoWidth Sizes the dropdown to its widest item, up to a max-width from the styles, instead of the control. On by default for a checklist, and for the comboboxes that quick filters create, so long results are not clipped.
maxSummaryItems How many of the selected items the summary of a checklist names: -1 names them all with the count after them, a positive number names that many and counts the rest (A, B, C +2), and 0 shows only the count (4 selected).
itemFilter Narrows the items an editor with in-place items offers, e.g. by the value of another field (editor.itemFilter = item => ...). The current value keeps showing even when it does not pass, and it does not apply to editors that search on the server.

The defaults for a whole application are in ComboboxEditor.defaults (emptyItemText, maxSummaryItems, ...), which can be set once in its script initialization. The empty item of an editor no longer has a text by default, so a select shows only its placeholder icon unless the editor or the defaults give it a text.

Lookup Editors

Editor Description
LookupEditor Dropdown from a lookup script.
ServiceLookupEditor Dropdown from a service lookup.
CheckLookupEditor Checkbox list from a lookup.

See Lookup Editors for details.

File Editors

Editor Description
FileUploadEditor Single file upload.
MultipleFileUploadEditor Multiple file upload.
ImageUploadEditor Single image upload.
MultipleImageUploadEditor Multiple image upload.

Rich Text Editors

Editor Description
HtmlContentEditor Rich HTML editor.
HtmlNoteContentEditor Rich HTML editor for notes.
HtmlReportContentEditor Rich HTML editor for reports.

Other Editors

Editor Description
Recaptcha reCAPTCHA widget.
CascadedWidgetLink Links a parent editor to a child editor (cascading).

ColorEditor (with a ColorPickerPanel popover) and DateRangeEditor (with predefined ranges) are part of StartSharp's pro extensions, not of corelib.

How Editors Are Selected

On the server side, a form property specifies its editor via an editor attribute:

[LookupEditor(typeof(CustomerRow))]
public string CustomerID { get; set; }

The attribute sets the editor type key (e.g. "Lookup") and editor options. The generated PropertyItem carries this to the client, where the PropertyGrid looks up the editor type in the EditorTypeRegistry and creates it with the given options.

Custom Editors

To create a custom editor, extend Widget (or EditorWidget), implement the value interfaces you need, and register it with registerEditor:

export class MyEditor extends Widget<MyEditorOptions> {
    static override [Symbol.typeInfo] = this.registerEditor("MyApp.MyEditor", [IGetEditValue, ISetEditValue]);
    // ...
}

See Custom Editors for details.

See Also