Custom Forms: Can I create a customized view to display individual submissions?

Topics: Administration, Writing themes
Dec 27, 2013 at 10:15 PM
In my theme I was able to customize the Index.cshtml and Item.cshtml files from Custom Forms (under ~/MyTheme/Views/Orchard.CustomForms/Admin/...). However, when you click on an individual submission the view used is from Orchard Core (/Contents/Views/Admin/Edit.cshtml).

I tried to create a structure in my theme to override that view. I know that it's hard. I also know that doing so will alter all content edit views. So I want to do it specifically for the custom form content type I created. I saw some posts on using the IThemeSelector to give a higher priority and coupling it to the content type (rightly or wrongly). But I don't know of any other way to accomplish this.

Essentially, I want to change how the submission is displayed. I prefer just a display much like CustomForms/Admin/Item.cshtml, although that view shows a list of the submissions - but it shows it without the editors.
Dec 28, 2013 at 5:16 PM
I am not sure if I am going about this the right way, but using an older post of Bertrand's, I am trying this:
using Orchard;
using Orchard.ContentManagement;
using Orchard.DisplayManagement.Descriptors;

namespace ModernRed.ShapeProviders
{
    public class ContentShapeProvider : IShapeTableProvider
    {
        private readonly IWorkContextAccessor _workContextAccessor;

        public ContentShapeProvider(IWorkContextAccessor workContextAccessor)
        {
            _workContextAccessor = workContextAccessor;
        }
        public void Discover(ShapeTableBuilder builder)
        {
            builder.Describe("Content.Edit")
                .OnDisplaying(displaying =>
                {
                    if (displaying.ShapeMetadata.DisplayType == "DetailAdmin")
                    {
                        ContentItem contentItem = displaying.Shape.ContentItem;
                        if (_workContextAccessor.GetContext().CurrentSite.HomePage.EndsWith(
                            ';' + contentItem.Id.ToString()))
                        {
                            displaying.ShapeMetadata.Alternates.Add("Orchard.CustomForms.Admin.Edit");
                        }
                    }
                });
        }
    }
}
I am thinking the Content.Edit form is the one I want to override, and am using "DetailAdmin" for the page in the Admin. My theme folder has this structure for the shape: "~/Themes/ModernRed/Views/Orchard.CustomForms/Admin/Edit.cshtml".

I am wanting to do this to get more power out of Custom Forms. Also, I would rather not create a module for every semi-complex form that I create. I could, but it's overkill in this situation. These forms are better suited to be created in the Admin Dashboard, and then I can take advantage of workflows to send out e-mails. Otherwise my modules would have inputs, validation, and use Orchard.Messaging to send out a templated e-mail (which is more powerful, flexible and I have full control) - but again, this is overkill.