RzTextEdit and RzTextField
The RzTextEdit
component provides basic text input functionality with support for prepend text or icons. It is intended as a low‑level input element for use within our form field components. The RzTextField
component wraps RzTextEdit
along with a label, help text, and validation messages, creating a complete form field experience. Both components are used within an EditForm
to enable model binding and validation.
Special Note
RizzyUI form controls depend on the Rizzy library for form control support. RizzyUI form controls provide client-side data annotations validation. Click here for specific Rizzy form control documentation.
RzTextEdit Example
In the example below an EditForm
is used with a single field that demonstrates the RzTextEdit
component. A prepend text of @
is applied to indicate that the field expects an email address.
<EditForm Model="Model" class="form-children-spacing">
<RzValidationSummary />
<RzField>
<RzFieldLabel DisplayName="Name" For="@(() => Model.Name)"></RzFieldLabel>
<RzTextEdit For="@(() => Model.Name)"/>
<RzValidationMessage For="@(() => Model.Name)" />
</RzField>
<RzField>
<RzFieldLabel DisplayName="Email" For="@(() => Model.Email)"></RzFieldLabel>
<RzTextEdit For="@(() => Model.Email)" PrependText="@("@")" />
<RzValidationMessage For="@(() => Model.Email)" />
</RzField>
</EditForm>
RzTextField Example
The RzTextField
component encapsulates a complete form field experience by combining a label, an input (via RzTextEdit
), optional help content, and validation messages. The example below shows how to use it inside an EditForm
.
<EditForm Model="Model" class="form-children-spacing">
<RzValidationSummary />
<RzTextField For="@(() => Model.PhoneNumber)" DisplayName="Phone Number" Role="@TextRole.Tel"
Placeholder="Enter your phone number.." PrependIcon="
">
<FieldHelp>This is a helpful description</FieldHelp>
</RzTextField>
<RzButton type="submit" Variant="ButtonVariant.Primary" Size="Size.Medium">
<span>Save</span>
</RzButton>
</EditForm>
Customer Model Reference
The following code defines a sample Customer
model that is used in these examples:
<!-- Customer.cs -->
<summary>
Represents a customer with personal and contact information.
</summary>
public class Customer
{
<summary>
Gets or sets the unique identifier for the customer.
</summary>
public int CustomerId { get; set; } = 1234;
<summary>
Gets or sets the full name of the customer.
</summary>
[MaxLength(10)]
public string Name { get; set; } = "Jane Johnson";
<summary>
Gets or sets the email address of the customer.
</summary>
public string Email { get; set; } = "johnsonj@gmail.com";
<summary>
Gets or sets the phone number of the customer.
</summary>
public string PhoneNumber { get; set; } = "555-555-5555";
<summary>
Gets or sets the age of the customer.
</summary>
public int Age { get; set; } = 29;
<summary>
Gets or sets a value indicating whether the customer is active.
</summary>
public bool IsActive { get; set; } = true;
<summary>
Gets or sets the gender of the customer.
</summary>
public string Gender { get; set; } = "female";
<summary>
Gets or sets the preferred method of contact for the customer.
</summary>
public string PreferredContactMethod { get; set; } = "email";
<summary>
Gets or sets the birth date of the customer.
</summary>
public DateTime BirthDate { get; set; } = DateTime.Now.AddYears(-29).AddMonths(3).AddDays(9);
<summary>
Gets or sets the interests of the customer.
This property is used to demonstrate the checkbox group components.
</summary>
public List<string> Interests { get; set; } = new List<string> { "Sports" };
}