Skip to content

Commit 1cbe657

Browse files
author
sinanbozkus
committed
From now you can add formhelper scripts to the head or body tag. Sample project updated to net core 3.1.
1 parent a7b24b0 commit 1cbe657

File tree

5 files changed

+23
-19
lines changed

5 files changed

+23
-19
lines changed

sample/FormHelper.Samples/FormHelper.Samples.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
4-
<TargetFramework>netcoreapp3.0</TargetFramework>
4+
<TargetFramework>netcoreapp3.1</TargetFramework>
55
</PropertyGroup>
66

77
<ItemGroup>
@@ -20,7 +20,7 @@
2020

2121

2222
<ItemGroup>
23-
<PackageReference Include="FluentValidation.AspNetCore" Version="8.5.0-preview5" />
23+
<PackageReference Include="FluentValidation.AspNetCore" Version="9.2.0" />
2424
</ItemGroup>
2525

2626
</Project>

sample/FormHelper.Samples/Startup.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ public Startup(IConfiguration configuration)
2121

2222
public void ConfigureServices(IServiceCollection services)
2323
{
24+
services.AddControllersWithViews()
25+
.AddFluentValidation();
26+
27+
// You can add these validators in a separate class.
28+
services.AddTransient<IValidator<ProductFormViewModel>, ProductFormViewModelValidator>();
29+
2430
// Add FormHelper to the project.
2531
services.AddFormHelper();
2632

@@ -31,12 +37,6 @@ public void ConfigureServices(IServiceCollection services)
3137
// RedirectDelay = 30,
3238
// ToastrDefaultPosition = ToastrPosition.BottomFullWidth
3339
//});
34-
35-
// You can add these validators in a separate class.
36-
services.AddTransient<IValidator<ProductFormViewModel>, ProductFormViewModelValidator>();
37-
38-
services.AddControllersWithViews()
39-
.AddFluentValidation();
4040
}
4141

4242
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)

sample/FormHelper.Samples/Views/Shared/_Layout.cshtml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,15 @@
88
<link rel="stylesheet" href="//stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" />
99
<link rel="stylesheet" href="~/css/site.css" />
1010

11-
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
12-
<script src="//stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.bundle.min.js"></script>
13-
14-
1511
<!-- form helper -->
1612
<link rel="stylesheet" href="/formhelper/formhelper.min.css" />
17-
<script src="/formhelper/formhelper.bundle.min.js"></script>
18-
<!-- remote modal -->
19-
<script src="//cdn.jsdelivr.net/gh/sinanbozkus/remotemodal/remotemodal.js"></script>
13+
14+
2015
</head>
2116
<body>
2217

2318
<div class="text-center mt-3">
24-
<h1 class="display-4"><img src="~/formhelper-logo.png" class="mb-2 mr-3" />Form Helper</h1>
19+
<h1 class="display-4"><img src="~/formhelper-logo.png" class="mb-2 mr-3" />Form Helper</h1>
2520
<p>Form & Validation Helper for <a href="https://dotnet.microsoft.com/learn/web/aspnet-hello-world-tutorial/intro" target="_blank">ASP.NET Core</a></p>
2621
</div>
2722

@@ -67,6 +62,12 @@
6762

6863
<script src="~/js/site.js" asp-append-version="true"></script>
6964

65+
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
66+
<script src="//stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.bundle.min.js"></script>
67+
<script src="/formhelper/formhelper.bundle.min.js"></script>
68+
<!-- remote modal -->
69+
<script src="//cdn.jsdelivr.net/gh/sinanbozkus/remotemodal/remotemodal.js"></script>
70+
7071
<script>
7172
$("#openModal").click(function () {
7273
RemoteModal("@Url.Action("Modal", "Home")");

src/FormHelper/FormHelper.csproj

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
<PropertyGroup>
44
<PackageId>FormHelper</PackageId>
5-
<Version>3.2.1</Version>
5+
<Version>3.2.3</Version>
66
<Authors>Sinan BOZKUS</Authors>
77
<projectUrl>https://github.com/sinanbozkus/FormHelper</projectUrl>
88
<RepositoryUrl>https://github.com/sinanbozkus/FormHelper</RepositoryUrl>
9-
<description>Form and Validation Helper for ASP.NET Core (Compatible with Fluent Validation)</description>
9+
<description>Transform server-side validations to client-side without writing any javascript code. (Compatible with Fluent Validation)</description>
1010
<Copyright>Copyright (c) Sinan Bozkus 2020</Copyright>
1111
<tags>fluentvalidation fluent validation form helper validation helper notification crud</tags>
1212
<PackageIconUrl>http://www.sinanbozkus.com/nuget/formhelper/formhelper-logo.png</PackageIconUrl>
@@ -19,8 +19,11 @@
1919
</PropertyGroup>
2020

2121
<ItemGroup>
22+
<None Remove="Styles\formhelper.css" />
23+
<None Remove="Styles\formhelper.min.css" />
2224
<None Remove="Scripts\formhelper.js" />
2325
<None Remove="Scripts\formhelper.min.js" />
26+
<None Remove="Scripts\formhelper.bundle.min.js" />
2427
</ItemGroup>
2528

2629
<ItemGroup>

src/FormHelper/TagHelpers/FormTagHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public async override Task ProcessAsync(TagHelperContext context, TagHelperOutpu
8989
output.Attributes.Add("enableButtonAfterSuccess", EnableButtonAfterSuccess);
9090
output.Attributes.Add("resetFormAfterSuccess", ResetFormAfterSuccess);
9191
output.Attributes.Add("checkTheFormFieldsMessage", configuration.CheckTheFormFieldsMessage);
92-
output.PostElement.AppendHtml($"<script>$(document).ready(function () {{$('#{formId}').UseFormHelper();}});</script>");
92+
output.PostElement.AppendHtml($"<script>window.addEventListener('load',function () {{$('#{formId}').UseFormHelper();}});</script>");
9393

9494
if (usedFormHelperTag)
9595
{

0 commit comments

Comments
 (0)