Inputs

Editors for text, numbers, dates, yes-or-no values and codes

Entering text and numbers

A string or number property is rendered as an HTML input element. The input's type is derived from the property: a number property is rendered as a number input, and a property with [EmailAddress], [Phone], [Url] or [DataType(DataType.Password)] as an email, phone, URL or password respectively.

To change the test editor's settings, call UseTextInputEditor(). The example below displays a euro sign before the price, and a placeholder in the phone number:

using StellarAdmin.Resources.Editors;

fields.Add(trip => trip.BasePrice).UseTextInputEditor(input =>
{
    input.Prefix = "€";
    input.Min = 0;
    input.Step = 10;
});
fields.Add(traveller => traveller.Phone).UseTextInputEditor(input =>
{
    input.Type = TextInputType.Tel;
    input.Placeholder = "+351 912 345 678";
});
The base price with a euro sign before it, and an empty phone number with its placeholder: Price
Price
The base price with a euro sign before it, and an empty phone number with its placeholder: Phone
Phone
SettingWhat it does
TypeSets the input's type: TextInputType.Text, Email, Tel, Url, Password or Number. The default comes from the property.
PlaceholderSets the text displayed while the input is empty.
Prefix, SuffixSets the text displayed before or after the input, such as € or km.
Min, MaxSets the smallest and largest number a number input accepts.
StepSets the interval between the numbers a number input accepts. The default is 1 for a whole-number property, and any number for other number properties.

Entering long text

A string property with [DataType(DataType.MultilineText)] is rendered as a textarea. To use a textarea for another string property, or to change the textarea's settings, call UseTextareaEditor():

fields.Add(trip => trip.Summary).UseTextareaEditor(textarea =>
{
    textarea.Rows = 4;
    textarea.Placeholder = "Two or three sentences for the trip card.";
});
An empty four-line summary textarea with its placeholder
SettingWhat it does
RowsSets the number of lines the textarea displays. Longer text scrolls. By default, the textarea grows with its text.
PlaceholderSets the text displayed while the textarea is empty.

For formatted text, use the rich text editor.

Entering dates and times

A DateOnly, DateTime or TimeOnly property is rendered as a date, date and time, or time input. You can also configure these editors by calling UseDateInputEditor(), UseDateTimeInputEditor() or UseTimeInputEditor(). The example below accepts only start dates from today:

fields.Add(departure => departure.StartDate).UseDateInputEditor(date =>
{
    date.Min = DateOnly.FromDateTime(DateTime.Today);
});
SettingWhat it does
Min, MaxSets the earliest and latest value the input accepts.
StepSets the interval between the values the input accepts: a number of days for a date input, and a TimeSpan for a date and time input or a time input. By default, the input accepts any value.

A DateTimeOffset property is rendered as a text input, so the value keeps its offset. That input ignores these settings.

A new record's DateOnly or DateTime property starts at 0001-01-01, the type's default value, so the input displays that date. To start the property at another date, set a default value.

Selecting boolean values

A bool property is rendered as a checkbox. To use a switch instead, call UseToggleEditor():

fields.Add(trip => trip.IsPublished).UseToggleEditor();
The trip's Published field as a checkbox and as a switch: Checkbox
Checkbox
The trip's Published field as a checkbox and as a switch: Switch
Switch

A bool? property is rendered as a select with Yes, No and Not set. The checkbox and the switch need a bool property, so for a bool? property, use one of the choice editors, such as a radio group.

A nullable Published field as a select and as a radio group: Select
Select
A nullable Published field as a select and as a radio group: Radio group
Radio group

Using a slider

To let people choose a number in a range by dragging a slider, call UseSliderEditor(). The example below lets people choose a group size from 2 to 16, with a mark at every second value:

fields.Add(trip => trip.MaxGroupSize).UseSliderEditor(slider =>
{
    slider.Min = 2;
    slider.Max = 16;
    slider.MarkInterval = 2;
    slider.ValueFormat = "{0} people";
});
A trip's group size on a slider from 2 to 16 people
SettingWhat it does
Min, MaxSets the range. The default comes from the property's [Range], and defaults to 0 to 100.
StepSets the interval between values. The default is 1.
ShowValueSets whether the current value is displayed beside the label. The default is true.
ValueFormatSets how values are displayed, with {0} for the number, such as "{0} km". The format also applies to the mark labels.
MarkIntervalSets the interval between marks. By default, the slider has no marks.
MarkLabelsSets which marks display their value: SliderMarkLabels.None, Ends or All. The default is Ends.
AddMark()Adds a mark at a value, with an optional label. Marks you add replace the marks from MarkInterval and MarkLabels.

Entering a code or PIN

To display one box for each digit of a code, such as a verification code or a PIN, call UseOneTimeCodeEditor(). The input accepts digits only. The example below displays a 4-digit badge code:

fields.Add(guide => guide.BadgeCode).UseOneTimeCodeEditor(code => code.Length = 4);
A guide's badge code with one box for each of its 4 digits

Length sets the number of digits. The default comes from the property's [StringLength] or [MaxLength], and is 6 by default.

On this page