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";
});



| Setting | What it does |
|---|---|
Type | Sets the input's type: TextInputType.Text, Email, Tel, Url, Password or Number. The default comes from the property. |
Placeholder | Sets the text displayed while the input is empty. |
Prefix, Suffix | Sets the text displayed before or after the input, such as € or km. |
Min, Max | Sets the smallest and largest number a number input accepts. |
Step | Sets 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.";
});

| Setting | What it does |
|---|---|
Rows | Sets the number of lines the textarea displays. Longer text scrolls. By default, the textarea grows with its text. |
Placeholder | Sets 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);
});| Setting | What it does |
|---|---|
Min, Max | Sets the earliest and latest value the input accepts. |
Step | Sets 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();



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.




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";
});

| Setting | What it does |
|---|---|
Min, Max | Sets the range. The default comes from the property's [Range], and defaults to 0 to 100. |
Step | Sets the interval between values. The default is 1. |
ShowValue | Sets whether the current value is displayed beside the label. The default is true. |
ValueFormat | Sets how values are displayed, with {0} for the number, such as "{0} km". The format also applies to the mark labels. |
MarkInterval | Sets the interval between marks. By default, the slider has no marks. |
MarkLabels | Sets 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);

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