Possible bug in LayoutProvider

Topics: Core, Customizing Orchard, Writing modules
Developer
Mar 2, 2012 at 10:59 PM
Edited Mar 2, 2012 at 11:00 PM

I just created an expirimental LayoutProvider called Accordion:

public void Describe(DescribeLayoutContext describe)
        {
            describe.For("Html", T("Html"), T("Html Layouts"))
                .Element("Accordion", T("Accordion"), T("Organizes content items in an accordion"),
                         DisplayLayout,
                         RenderLayout,
                         null // form
                );
        }

Notice that I pass "null" as the form, as this particular layout does not require additional configuration

However, it looks like passing in null causes an exception exception in DefaultFormManager:

public dynamic Build(string formName, string prefix = "") {
            var context = new DescribeContext();
            foreach (var provider in _formProviders) {
                provider.Describe(context);
            }

            var descriptor = context.Describe().First(x => x.Name == formName);

The last line throws an "System.InvalidOperationException: Sequence contains no matching element".

To avoid that exception, I need to create a class that implements IFormProvider and return a Form shape with some Id. Then I use that Id in the LayoutProvider instead of null.

I am just trying to understand if this is the way that it should be, or that providing a custom form should be optional (as the Element signature suggests, since form = null by default)

 

 

 

Coordinator
Mar 2, 2012 at 11:04 PM

You are right, please file a bug. I'll fix it right now.

Coordinator
Mar 2, 2012 at 11:05 PM

By the way feedback is greatly appreciated on this module. We can enhance it if needed, like to enable some scenarios.

Developer
Mar 2, 2012 at 11:07 PM

Bug has been filed: http://orchard.codeplex.com/workitem/18512

Developer
Mar 2, 2012 at 11:12 PM
sebastienros wrote:

By the way feedback is greatly appreciated on this module. We can enhance it if needed, like to enable some scenarios.

Absolutely! I'll be making a lot of use of this powerhouse module.