diff --git a/src/OrchardCore.Modules/OrchardCore.Forms/FormShapeTableProvider.cs b/src/OrchardCore.Modules/OrchardCore.Forms/FormShapeTableProvider.cs new file mode 100644 index 00000000000..e31fc981180 --- /dev/null +++ b/src/OrchardCore.Modules/OrchardCore.Forms/FormShapeTableProvider.cs @@ -0,0 +1,24 @@ +using OrchardCore.ContentManagement; +using OrchardCore.DisplayManagement; +using OrchardCore.DisplayManagement.Descriptors; +using OrchardCore.DisplayManagement.Utilities; +using OrchardCore.Forms.Models; + +namespace OrchardCore.Forms; + +public class FormShapeTableProvider : IShapeTableProvider +{ + public void Discover(ShapeTableBuilder builder) + { + builder.Describe("Widget__Form") + .OnDisplaying(context => + { + if (context.Shape.TryGetProperty("ContentItem", out var contentItem) + && contentItem.TryGet(out var elementPart) + && !string.IsNullOrEmpty(elementPart.Id)) + { + context.Shape.Metadata.Alternates.Add($"Widget__{contentItem.ContentType}_{elementPart.Id.EncodeAlternateElement()}"); + } + }); + } +} diff --git a/src/OrchardCore.Modules/OrchardCore.Forms/OrchardCore.Forms.csproj b/src/OrchardCore.Modules/OrchardCore.Forms/OrchardCore.Forms.csproj index 5fd207b8e74..efffbdfae49 100644 --- a/src/OrchardCore.Modules/OrchardCore.Forms/OrchardCore.Forms.csproj +++ b/src/OrchardCore.Modules/OrchardCore.Forms/OrchardCore.Forms.csproj @@ -17,6 +17,7 @@ + diff --git a/src/OrchardCore.Modules/OrchardCore.Forms/Startup.cs b/src/OrchardCore.Modules/OrchardCore.Forms/Startup.cs index 507fe60bc52..d529cfb5a7d 100644 --- a/src/OrchardCore.Modules/OrchardCore.Forms/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Forms/Startup.cs @@ -4,6 +4,7 @@ using OrchardCore.ContentManagement; using OrchardCore.ContentManagement.Display.ContentDisplay; using OrchardCore.Data.Migration; +using OrchardCore.DisplayManagement.Descriptors; using OrchardCore.Forms.Activities; using OrchardCore.Forms.Activities.Drivers; using OrchardCore.Forms.Drivers; @@ -76,6 +77,7 @@ public override void ConfigureServices(IServiceCollection services) .UseDisplayDriver(); services.AddDataMigration(); + services.AddScoped(); } } diff --git a/src/OrchardCore.Modules/OrchardCore.Forms/Views/Items/ButtonPart.Fields.Edit.cshtml b/src/OrchardCore.Modules/OrchardCore.Forms/Views/Items/ButtonPart.Fields.Edit.cshtml index e10a9ceec0c..6801b9f899a 100644 --- a/src/OrchardCore.Modules/OrchardCore.Forms/Views/Items/ButtonPart.Fields.Edit.cshtml +++ b/src/OrchardCore.Modules/OrchardCore.Forms/Views/Items/ButtonPart.Fields.Edit.cshtml @@ -14,9 +14,9 @@
@T["The button type."]
diff --git a/src/OrchardCore.Modules/OrchardCore.Forms/Views/Items/FormElementLabelPart.Fields.Edit.cshtml b/src/OrchardCore.Modules/OrchardCore.Forms/Views/Items/FormElementLabelPart.Fields.Edit.cshtml index 1547f36d117..11ea7e5cee4 100644 --- a/src/OrchardCore.Modules/OrchardCore.Forms/Views/Items/FormElementLabelPart.Fields.Edit.cshtml +++ b/src/OrchardCore.Modules/OrchardCore.Forms/Views/Items/FormElementLabelPart.Fields.Edit.cshtml @@ -11,9 +11,9 @@
@T["The type of label to create for this field."]
diff --git a/src/OrchardCore.Modules/OrchardCore.Forms/Views/Items/InputPart.Fields.Edit.cshtml b/src/OrchardCore.Modules/OrchardCore.Forms/Views/Items/InputPart.Fields.Edit.cshtml index e82d65d00d7..076d4bffb99 100644 --- a/src/OrchardCore.Modules/OrchardCore.Forms/Views/Items/InputPart.Fields.Edit.cshtml +++ b/src/OrchardCore.Modules/OrchardCore.Forms/Views/Items/InputPart.Fields.Edit.cshtml @@ -51,7 +51,7 @@ diff --git a/src/OrchardCore.Modules/OrchardCore.Forms/Views/Items/InputPart.cshtml b/src/OrchardCore.Modules/OrchardCore.Forms/Views/Items/InputPart.cshtml index 99535870161..0082bd6b486 100644 --- a/src/OrchardCore.Modules/OrchardCore.Forms/Views/Items/InputPart.cshtml +++ b/src/OrchardCore.Modules/OrchardCore.Forms/Views/Items/InputPart.cshtml @@ -7,7 +7,7 @@ var fieldName = formInputElementPart.Name; var fieldId = !string.IsNullOrEmpty(elementId) ? elementId : !string.IsNullOrEmpty(fieldName) ? Html.GenerateIdFromName(fieldName) : default(string); var fieldValue = Model.Value.DefaultValue; - var fieldClass = "form-control"; + var fieldClass = Model.Value.Type == "checkbox" ? "form-check-input" : "form-control"; var isChecked = false; if (ViewData.ModelState.TryGetValue(fieldName, out var fieldEntry)) @@ -23,9 +23,9 @@ if (fieldEntry.Errors.Count > 0) { - fieldClass = "form-control input-validation-error is-invalid"; + fieldClass += " input-validation-error is-invalid"; } } } - +