Search K
Appearance
A EmailField
can be used to store email addresses. All text entered must be a valid email address. The underlying type of the field is string
.
In our demo application we use a string property Email
to store an employee's email address.
public class Employee
{
[Key]
public int Id { get; init; }
[Required]
public string Email { get; set; }
}
We can then represent the property with a EmailField
in the employee resource.
public override IList<IResourceFieldBuilder> Fields()
{
return
[
EmailField.Make("Email", nameof(Employee.Email)),
];
}
An EmailField
can be set as display name of an entity, by chaining AsDisplayName()
after field initialization. You can choose more than one field for the display name. Please note that the order the fields are added in is also the order of the display name parts.
public override IList<IResourceFieldBuilder> Fields()
{
return
[
EmailField.Make("Email", nameof(Employee.Email))
.AsDisplayName(),
];
}
Setting a display name results in the following behavior in the UI:
An EmailField
displays its value as a link with a mailto modifier.
In Create and Update views a user will see a one-line text input field. Invalid email addresses will be rejected by validation.
The default visibility values are as follows:
Resource View | Default |
---|---|
Index | visible |
Create | visible |
Update | visible |
Details | visible |
You can change the visibility of the field for each view. Please note, however, that fields should remain visible on Create pages if the field is required by the entity model and if no default value is set.
A EmailField
can be made sortable by chaining a call to Sortable()
after adding the field. Sorting will be performed alphanumerically.
public override IList<IResourceFieldBuilder> Fields()
{
return
[
EmailField.Make("Email", nameof(Employee.Email))
.Sortable(),
];
}
Since email fields are of type string
, they can be made searchable by adding a search engine to the resource.