You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As a follow up to #15488
When a custom validation is required in the UpdateEditorAsync method of a display driver.
The asp-for taghelper doesn't display the proper mutated value.
This can be fixed by updating the updater.ModelState in that method because this is what the asp-for taghelper uses to display a value.
We may find a better fix than updating manually the updater.ModelState.
public override async Task<IDisplayResult> UpdateAsync(
CreateSite model,
ProjectDetails section,
IUpdateModel updater,
UpdateEditorContext context
)
{
var viewModel = new ProjectDetailsViewModel();
await context.Updater.TryUpdateModelAsync(viewModel, Prefix);
section.ProjectName = viewModel.ProjectName.ToSafeName();
// This is the fix to get the proper value to display with the asp-for taghelper
context.Updater.ModelState.SetModelValue(
$"{Prefix}.{nameof(section.ProjectName)}",
section.ProjectName,
section.ProjectName
);
// After removing special chars ProjectName could become an empty string.
if (string.IsNullOrWhiteSpace(section.ProjectName))
{
updater.ModelState.AddModelError(Prefix, nameof(section.ProjectName), S["Project name is required"]);
}
}
We triaged this issue and set the milestone according to the priority we think is appropriate (see the docs on how we triage and prioritize issues).
This indicates when the core team may start working on it. However, if you'd like to contribute, we'd warmly welcome you to do that anytime. See our guide on contributions here.
As a follow up to #15488
When a custom validation is required in the UpdateEditorAsync method of a display driver.
The asp-for taghelper doesn't display the proper mutated value.
This can be fixed by updating the updater.ModelState in that method because this is what the asp-for taghelper uses to display a value.
We may find a better fix than updating manually the updater.ModelState.
@sebastienros @deanmarcussen
The text was updated successfully, but these errors were encountered: