Virtually all web apps nowadays have support for masked inputs. Not quite sure why Telerik Blazor does not, but requesting it, since I can't really go live without it.
Ideally it should also work using data annotations on the model class using [DataType(DataType.Password)]. This way I don't have to specify the form fields and can just rely on the auto-generated form (like I am doing now). I have a lot of forms that have passwords, so it would be annoying to have to specify the fields for all of them.
As per the current component configuration, when the EditContext changes, the Form descendants are not disposed and recreated. Thus when the change occurs, you need to explicitly add any validation (be that DataAnnotationsValidation or custom one).
This request serves for indicating research on how the Form behavior could be improved upon changing the EditContext.
The Validation does not trigger when I load my model from an async method.
<AdminEdit>
A workaround for the time being:
@inject HttpClient http
@using System.ComponentModel.DataAnnotations
<TelerikForm @ref="@EditForm"
Model="@TheCatFactTelerik"
ValidationMessageType="@FormValidationMessageType.None">
<FormValidation>
<ValidationSummary />
</FormValidation>
<FormItems>
<FormItem Field="fact">
</FormItem>
</FormItems>
<FormButtons>
<TelerikButton ButtonType="ButtonType.Submit" Primary="true">Apply</TelerikButton>
</FormButtons>
</TelerikForm>
@code {
public TelerikForm EditForm { get; set; }
public CatFact TheCatFactTelerik = new CatFact();
public EditContext editContext { get; set; }
protected async override Task OnInitializedAsync()
{
TheCatFactTelerik = await http.GetFromJsonAsync<CatFact>("https://catfact.ninja/fact");
}
protected override async Task OnAfterRenderAsync(bool firstRender)
{
EditForm.EditContext.AddDataAnnotationsValidation();
}
public class CatFact
{
[Required(ErrorMessage = "Required Error Text")]
[MinLength(10, ErrorMessage = "Min Length 10")]
public string fact { get; set; }
public int length { get; set; }
}
}
</AdminEdit>
Telerik TextBox for string is nice but what about something like [DataType(DataType.MultilineText)] for TextArea?
Forms should really come with Text Area. It seems like a good one to do next.
Blazor Form Overview | Telerik UI for Blazor
---
ADMIN EDIT
An idea is that perhaps other data type annotations could be used - perhaps Date, DateTime, TIme can switch different date/time pickers, Html can generate the HTML editor, Password can set a textbox with the Password type
---
Would be greate if we could expose ValidateOn to FormItem's. That way we could put:
<FormItem ValidateOn="ValidationEvent.Change" />
Rather than needing to specify a template, which feels a little unnecessary. If the datatype for the FormItem uses a field that doesn't use ValidateOn, it can simply be ignored, but for things like strings, numbers etc this would be useful.
Also a top level ValidateOn in the TelerikForm component could be useful, so you can set it once for the form, then maybe override it more granularly.
I would like to change the location of the Form Buttons. Instead of having them at the bottom of the form, I would like them to be at the top of the form.
Please allow customizing of the Form Buttons position.
===========
ADMIN EDIT
===========
If you want to position the Form Buttons on top of the Form you can try the following approach - use FormItem Template and place the desired buttons in it. For example:
@using System.ComponentModel.DataAnnotations
<TelerikForm EditContext="@theEditContext" OnValidSubmit="@OnValidSubmitHandler" Width="200px">
<FormItems>
<FormItem>
<Template>
<TelerikButton ButtonType="@ButtonType.Submit" Primary="true">Submit</TelerikButton>
<TelerikButton ButtonType="@ButtonType.Button" OnClick="@ClearButton">Clear</TelerikButton>
</Template>
</FormItem>
<FormItem Field="FirstName"></FormItem>
<FormItem Field="LastName"></FormItem>
<FormItem Field="DOB"></FormItem>
</FormItems>
<FormButtons>
</FormButtons>
</TelerikForm>
@code {
private void ClearButton()
{
person = new Person();
CreatedEditContext(person);
}
void CreatedEditContext(Person model)
{
theEditContext = new EditContext(model);
theEditContext.AddDataAnnotationsValidation();
}
Person person { get; set; } = new Person();
EditContext theEditContext { get; set; }
protected override async Task OnInitializedAsync()
{
person = new Person();
CreatedEditContext(person);
}
async Task OnValidSubmitHandler()
{
Console.WriteLine($"SAVING {person.FirstName} {person.LastName} who was born on {person.DOB}");
}
public class Person
{
[Required]
public string FirstName { get; set; }
[Required]
public string LastName { get; set; }
public DateTime DOB { get; set; }
}
}
Currently, the Form component does not provide indexer support, or binding to an item of collection. For reference of the feature, you could observe the following documentation of the WPF suite:
https://docs.telerik.com/devtools/wpf/controls/radpropertygrid/features/indexer-support
I need a way to use TelerikForms and make it responsive for various display sizes.
Here is what I'm trying to accomplish: I have a TelerikForm with 5 columns. it looks nice horizontally on the screen, but I need it to respond to screen size and start stacking vertically when the screen is shrunk.
I have a simple TelerikForm using required validation but for some reason when I set the model via an async call to the server the validation doesn't fire. I am using the same form when I add a new item and the validation is working fine.