mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
Removed changes to model bindings (#8412)
This is the same as reverting 1.10.x to commit 868ce12ad6
This commit is contained in:
@@ -1,27 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Web.Mvc;
|
|
||||||
|
|
||||||
namespace Orchard.Mvc.ModelBinders {
|
|
||||||
public class BooleanBinderProvider : IModelBinderProvider, IModelBinder {
|
|
||||||
|
|
||||||
public IEnumerable<ModelBinderDescriptor> GetModelBinders() {
|
|
||||||
return new[] {
|
|
||||||
new ModelBinderDescriptor {
|
|
||||||
ModelBinder = this,
|
|
||||||
Type = typeof(bool)
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) {
|
|
||||||
var value = false;
|
|
||||||
if (string.IsNullOrWhiteSpace(controllerContext.HttpContext.Request[bindingContext.ModelName])) return false;
|
|
||||||
var requestBooleanValue = controllerContext.HttpContext.Request[bindingContext.ModelName].Split(',')[0]; //Html.CheckBox and Html.CheckBoxFor return "true,false" string
|
|
||||||
if (!bool.TryParse(requestBooleanValue, out value)) {
|
|
||||||
bindingContext.ModelState.AddModelError(bindingContext.ModelName, new FormatException());
|
|
||||||
}
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -182,7 +182,6 @@
|
|||||||
<Compile Include="Data\Migration\Schema\DropUniqueConstraintCommand.cs" />
|
<Compile Include="Data\Migration\Schema\DropUniqueConstraintCommand.cs" />
|
||||||
<Compile Include="Environment\Extensions\Models\LifecycleStatus.cs" />
|
<Compile Include="Environment\Extensions\Models\LifecycleStatus.cs" />
|
||||||
<Compile Include="Environment\ShellBuilders\ICompositionStrategy.cs" />
|
<Compile Include="Environment\ShellBuilders\ICompositionStrategy.cs" />
|
||||||
<Compile Include="Mvc\ModelBinders\BooleanBinderProvider.cs" />
|
|
||||||
<Compile Include="Mvc\Updater.cs" />
|
<Compile Include="Mvc\Updater.cs" />
|
||||||
<Compile Include="Recipes\Models\ConfigurationContext.cs" />
|
<Compile Include="Recipes\Models\ConfigurationContext.cs" />
|
||||||
<Compile Include="Recipes\Models\RecipeBuilderStepConfigurationContext.cs" />
|
<Compile Include="Recipes\Models\RecipeBuilderStepConfigurationContext.cs" />
|
||||||
|
|||||||
Reference in New Issue
Block a user