-
+
<#
foreach (var property in entityProperties)
{
@@ -44,10 +44,11 @@
string propertyShortTypeName = property.ShortTypeName.Replace("?", string.Empty);
var inputTypeName = Model.GetInputType(propertyShortTypeName);
var inputClass = Model.GetInputClassType(propertyShortTypeName);
+ var requiredAttributeHtml = property.IsRequired ? "aria-required=\"true\"" : string.Empty;
#>
- <<#= inputTypeName #> id="<#= modelPropertyNameLowercase #>" @bind-Value="<#= modelName #>.<#= modelPropertyName #>" class="<#= inputClass #>" />
+ <<#= inputTypeName #> id="<#= modelPropertyNameLowercase #>" @bind-Value="<#= modelName #>.<#= modelPropertyName #>" class="<#= inputClass #>" <#= requiredAttributeHtml #>/>
<# } #>
diff --git a/src/Scaffolding/VS.Web.CG.Mvc/Templates/Blazor/Edit.cs b/src/Scaffolding/VS.Web.CG.Mvc/Templates/Blazor/Edit.cs
index d7821bd9f..f7d47b8b6 100644
--- a/src/Scaffolding/VS.Web.CG.Mvc/Templates/Blazor/Edit.cs
+++ b/src/Scaffolding/VS.Web.CG.Mvc/Templates/Blazor/Edit.cs
@@ -65,7 +65,8 @@ public virtual string TransformText()
this.Write("\" OnValidSubmit=\"Update");
this.Write(this.ToStringHelper.ToStringWithCulture(modelName));
this.Write("\" FormName=\"edit\" Enhance>\r\n \r\n " +
- " \r\n \r\n \r\n \r\n ");
+ this.Write("\" ");
+ this.Write(this.ToStringHelper.ToStringWithCulture(requiredHtml));
+ this.Write("/>\r\n ");
this.Write(this.ToStringHelper.ToStringWithCulture(modelName));
this.Write(".");
this.Write(this.ToStringHelper.ToStringWithCulture(modelPropertyName));
diff --git a/src/Scaffolding/VS.Web.CG.Mvc/Templates/Blazor/Edit.tt b/src/Scaffolding/VS.Web.CG.Mvc/Templates/Blazor/Edit.tt
index 3eb03a18e..493426d5b 100644
--- a/src/Scaffolding/VS.Web.CG.Mvc/Templates/Blazor/Edit.tt
+++ b/src/Scaffolding/VS.Web.CG.Mvc/Templates/Blazor/Edit.tt
@@ -45,7 +45,7 @@ else
-
+
<#
foreach (var property in entityProperties)
@@ -55,10 +55,11 @@ else
string propertyShortTypeName = property.ShortTypeName.Replace("?", string.Empty);
var inputTypeName = Model.GetInputType(propertyShortTypeName);
var inputClass = Model.GetInputClassType(propertyShortTypeName);
+ var requiredHtml = property.IsRequired ? "aria-required=\"true\"" : string.Empty;
#>
- <<#= inputTypeName #> id="<#= modelPropertyNameLowercase #>" @bind-Value="<#= modelName #>.<#= modelPropertyName #>" class="<#= inputClass #>" />
+ <<#= inputTypeName #> id="<#= modelPropertyNameLowercase #>" @bind-Value="<#= modelName #>.<#= modelPropertyName #>" class="<#= inputClass #>" <#= requiredHtml #>/>
<# } #>
diff --git a/src/Scaffolding/VS.Web.CG.Mvc/Templates/RazorPageGenerator/Bootstrap5/Create.cshtml b/src/Scaffolding/VS.Web.CG.Mvc/Templates/RazorPageGenerator/Bootstrap5/Create.cshtml
index affa4b8b3..57e127100 100644
--- a/src/Scaffolding/VS.Web.CG.Mvc/Templates/RazorPageGenerator/Bootstrap5/Create.cshtml
+++ b/src/Scaffolding/VS.Web.CG.Mvc/Templates/RazorPageGenerator/Bootstrap5/Create.cshtml
@@ -1,4 +1,4 @@
-@inherits Microsoft.VisualStudio.Web.CodeGeneration.Templating.RazorTemplateBase
+@inherits Microsoft.VisualStudio.Web.CodeGeneration.Templating.RazorTemplateBase
@using Microsoft.VisualStudio.Web.CodeGeneration.EntityFrameworkCore
@using System.Collections.Generic
@using System.Linq
@@ -11,47 +11,49 @@
}
else if (Model.IsLayoutPageSelected)
{
-@:@@{
- @:ViewData["Title"] = "@Model.RazorPageName";
+ @:@@{
+ @:ViewData["Title"] = "@Model.RazorPageName";
if (!string.IsNullOrEmpty(Model.LayoutPageFile))
{
- @:Layout = "@Model.LayoutPageFile";
+ @:Layout = "@Model.LayoutPageFile";
}
-@:}
-@:
-@:@Model.RazorPageName
-@:
+ @:}
+ @:
+ @:@Model.RazorPageName
+ @:
}
else
{
-@:@@{
- @:Layout = null;
-@:}
-@:
-@:
-@:
-@:
-@:
- @:
- @:@Model.RazorPageName
-@:
-@:
-@:
+ @:@@{
+ @:Layout = null;
+ @:}
+ @:
+ @:
+ @:
+ @:
+ @:
+ @:
+ @:@Model.RazorPageName
+ @:
+ @:
+ @:
// PushIndent(" ");
}
-@:@Model.ViewDataTypeShortName
-@:
-@:
+ @:
@Model.ViewDataTypeShortName
+ @:
+ @: