mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-04-05 21:01:35 +08:00
Fixed duplicate field shape issue with Content Field elements.
Fixes #5974
This commit is contained in:
parent
68b3fe56d0
commit
3a7091467b
@ -33,7 +33,7 @@ namespace Orchard.Layouts.Services {
|
||||
var drivers = GetFieldDrivers(field.FieldDefinition.Name);
|
||||
|
||||
drivers.Invoke(driver => {
|
||||
var result = driver.BuildDisplayShape(context);
|
||||
var result = Filter(driver.BuildDisplayShape(context), field);
|
||||
if (result != null)
|
||||
result.Apply(context);
|
||||
}, Logger);
|
||||
@ -67,6 +67,21 @@ namespace Orchard.Layouts.Services {
|
||||
return context.Shape;
|
||||
}
|
||||
|
||||
private DriverResult Filter(DriverResult driverResult, ContentField field) {
|
||||
DriverResult result = null;
|
||||
var combinedResult = driverResult as CombinedResult;
|
||||
var contentShapeResult = driverResult as ContentShapeResult;
|
||||
|
||||
if (combinedResult != null) {
|
||||
result = combinedResult.GetResults().SingleOrDefault(x => x.ContentField != null && x.ContentField.Name == field.Name);
|
||||
}
|
||||
else if (contentShapeResult != null) {
|
||||
result = contentShapeResult.ContentField != null && contentShapeResult.ContentField.Name == field.Name ? contentShapeResult : driverResult;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private IEnumerable<IContentFieldDriver> GetFieldDrivers(string fieldName) {
|
||||
return _contentFieldDrivers.Where(x => x.GetType().BaseType.GenericTypeArguments[0].Name == fieldName);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user