Skip to content

Commit

Permalink
.NET 7 support
Browse files Browse the repository at this point in the history
  • Loading branch information
sinanbozkus committed Nov 23, 2022
1 parent d17b9f1 commit 65ca3b8
Show file tree
Hide file tree
Showing 11 changed files with 76 additions and 43 deletions.
23 changes: 15 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
# Form Helper

If you like this library and want to support it, please give a star. :star:
###\#1 Form Library for ASP.NET Core MVC

If you like this library and want to support it, please give a star. :star:

Form & Validation Helper for **ASP.NET Core**
Form & Validation Helper for **ASP.NET Core MVC**

Form Helper helps you to create ajax forms and validations without writing any javascript code. **It transforms server-side validations to client-side.** You can also use the form validator without ajax.

**Compatible with Fluent Validation**
####**Compatible with Fluent Validation** :white_check_mark:
(You can add client-side validation support to Fluent Validation.)

[![NuGet](https://img.shields.io/nuget/v/FormHelper.svg)](https://nuget.org/packages/FormHelper) [![Nuget](https://img.shields.io/nuget/dt/FormHelper.svg)](https://nuget.org/packages/FormHelper) [![Gitter](https://badges.gitter.im/formhelper/community.svg)](https://gitter.im/formhelper/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
[![NuGet](https://img.shields.io/nuget/v/FormHelper.svg)](https://nuget.org/packages/FormHelper) [![Nuget](https://img.shields.io/nuget/dt/FormHelper.svg)](https://nuget.org/packages/FormHelper)

<p align="center">
<img src="http://www.sinanbozkus.com/nuget/formhelper/formhelper-screenshot.png" alt="FormHelper" />
Expand Down Expand Up @@ -57,6 +58,7 @@ services.AddControllersWithViews().AddFormHelper(options => {
options.CheckTheFormFieldsMessage = "Your custom message...";
options.RedirectDelay = 6000;
options.EmbeddedFiles = true;
options.ToastrDefaultPosition = ToastrPosition.TopFullWidth;
});
```
Configure:
Expand Down Expand Up @@ -117,21 +119,26 @@ return FormResult.CreateSuccessResult("Product saved. Please wait...", Url.Actio
$("#formId").fillFormFields(yourJsonObject);
```

**Reset form and clear error messages:**
```
$("#formId").fhReset();
```

**Toastr:**

Success:
```
formHelperToastr.success("Text here");
fhToastr.success("Text here");
```
Warning:
```
formHelperToastr.warning("Text here");
fhToastr.warning("Text here");
```
Information:
```
formHelperToastr.information("Text here");
fhToastr.information("Text here");
```
Error:
```
formHelperToastr.error("Text here");
fhToastr.error("Text here");
```
14 changes: 11 additions & 3 deletions dist/formhelper.bundle.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/formhelper.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions sample/FormHelper.Samples/FormHelper.Samples.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand All @@ -18,7 +18,7 @@


<ItemGroup>
<PackageReference Include="FluentValidation.AspNetCore" Version="11.1.0" />
<PackageReference Include="FluentValidation.AspNetCore" Version="11.2.2" />
</ItemGroup>

</Project>
26 changes: 13 additions & 13 deletions sample/FormHelper.Samples/Views/Home/TagHelper.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
</div>
<div class="card-body">
<!-- You can use <form asp-formhelper="true"> or <formhelper> to activate formhelper. -->
<form asp-formhelper="true" asp-controller="Home" asp-action="Save" asp-dataType="FormData"
asp-callback="ProductFormCallback" asp-beforeSubmit="ProductFormBeforeSubmit"
<form id="sample-form" asp-formhelper="true" asp-controller="Home" asp-action="Save" asp-dataType="FormData"
asp-callback="ProductFormCallback" asp-beforeSubmit="ProductFormBeforeSubmit"
asp-enableButtonAfterSuccess="true" asp-resetFormAfterSuccess="false"
enctype="multipart/form-data">

Expand Down Expand Up @@ -61,7 +61,7 @@
</div>
<hr />
<div class="form-group text-right">
<button class="btn btn-secondary" type="reset">Reset</button>
<button id="sinan" class="btn btn-secondary" type="button" onclick="$(this).closest('form').fhReset();">Reset</button>
<button class="btn btn-primary" type="submit">Save</button>
</div>
</form>
Expand All @@ -73,14 +73,14 @@


@section Scripts {
<script>
var ProductFormBeforeSubmit = function (rr, $form, options) {
console.log("BeforeSubmit function!");
}
var ProductFormCallback = function (response, statusText, xhr, $form) {
console.log(response);
console.log("Callback function!");
}
</script>
<script>
var ProductFormBeforeSubmit = function (rr, $form, options) {
console.log("BeforeSubmit function!");
}
var ProductFormCallback = function (response, statusText, xhr, $form) {
console.log(response);
console.log("Callback function!");
}
</script>
}
16 changes: 11 additions & 5 deletions src/FormHelper/FormHelper.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<PackageId>FormHelper</PackageId>
<Version>5.0.0-beta4</Version>
<Version>5.0.0</Version>
<Authors>Sinan BOZKUS</Authors>
<projectUrl>https://github.com/sinanbozkus/FormHelper</projectUrl>
<RepositoryUrl>https://github.com/sinanbozkus/FormHelper</RepositoryUrl>
Expand All @@ -20,7 +20,7 @@
</ItemGroup>

<PropertyGroup>
<TargetFrameworks>netcoreapp31;net50;net60</TargetFrameworks>
<TargetFrameworks>netcoreapp31;net50;net60;net70</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
Expand Down Expand Up @@ -68,8 +68,14 @@
<PackageReference Include="Microsoft.Extensions.FileProviders.Embedded" Version="6.0.0" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="BuildBundlerMinifier" Version="3.2.449" />
<ItemGroup Condition="'$(TargetFramework)' == 'net70'">
<FrameworkReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.FileProviders.Embedded" Version="7.0.0" />
</ItemGroup>

</Project>
<!-- <ItemGroup>-->
<!-- <PackageReference Include="BuildBundlerMinifier" Version="3.2.449" />-->
<!-- </ItemGroup>-->

</Project>
14 changes: 11 additions & 3 deletions src/FormHelper/Scripts/formhelper.bundle.min.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/FormHelper/Scripts/formhelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -799,5 +799,6 @@
this.find("input[type='submit'],button[type='submit']").removeAttr(
"disabled"
);
this.find("[class*='field-validation']").empty();
};
})(jQuery);
2 changes: 1 addition & 1 deletion src/FormHelper/Scripts/formhelper.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/FormHelper/Scripts/jquery.validate.min.js

Large diffs are not rendered by default.

13 changes: 8 additions & 5 deletions src/FormHelper/Scripts/jquery.validate.unobtrusive.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 65ca3b8

Please sign in to comment.