mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Fixed an issue with a potentially null controller.
When the indexing background task displays content with a Form element, the driver was throwing a NRE because of a null controller.
This commit is contained in:
@@ -130,15 +130,15 @@ namespace Orchard.DynamicForms.Drivers {
|
|||||||
|
|
||||||
protected override void OnDisplaying(Form element, ElementDisplayContext context) {
|
protected override void OnDisplaying(Form element, ElementDisplayContext context) {
|
||||||
var controller = _currentControllerAccessor.CurrentController;
|
var controller = _currentControllerAccessor.CurrentController;
|
||||||
var values = controller.FetchPostedValues(element);
|
var modelState = controller != null ? controller.FetchModelState(element) : default(ModelStateDictionary);
|
||||||
var modelState = controller.FetchModelState(element);
|
|
||||||
|
|
||||||
if (modelState != null && !modelState.IsValid) {
|
if (modelState != null && !modelState.IsValid) {
|
||||||
// Read any posted values from the previous request.
|
// Read any posted values from the previous request.
|
||||||
|
var values = controller.FetchPostedValues(element);
|
||||||
_formService.ReadElementValues(element, new NameValueCollectionValueProvider(values, _cultureAccessor.CurrentCulture));
|
_formService.ReadElementValues(element, new NameValueCollectionValueProvider(values, _cultureAccessor.CurrentCulture));
|
||||||
|
|
||||||
// Add any model validation errors from the previous request.
|
// Add any model validation errors from the previous request.
|
||||||
controller.ApplyAnyModelErrors(element, modelState);
|
controller.ApplyAnyModelErrors(element, modelState);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Assign the binding content type to each element within the form element.
|
// Assign the binding content type to each element within the form element.
|
||||||
|
Reference in New Issue
Block a user