private static string BuildFormSummaryTag( string formSummaryId, MiruValidationException validationException, ExceptionResultContext m) { var formSummary = m.GetService <HtmlGenerator>() .FormSummaryFor(validationException.Model) .RemoveAttr("hidden"); // TODO: get from htmlconventions var turboStreamTag = new TurboStreamTag("replace", formSummaryId) .AppendIntoTemplate(formSummary); validationException.Errors.Each(error => formSummary.Add("div", tag => tag.Text(error.ErrorMessage))); return(turboStreamTag.ToString()); }
private static StringBuilder BuildValidationMessageTags(MiruValidationException validationException) { var html = new StringBuilder(); foreach (var error in validationException.Errors) { var inputId = ElementNaming.BuildId(error.PropertyName); var validationMessageTagId = $"{inputId}-validation"; var validationMessageTag = new InputValidationTag(validationMessageTagId, inputId, error.ErrorMessage); var turboStreamTag = new TurboStreamTag("replace", validationMessageTagId) .AppendIntoTemplate(validationMessageTag); html.AppendLine(turboStreamTag.ToString()); } return(html); }