How do I render a form I created with IFormProvider on the front-end?

Topics: Customizing Orchard, General
Jun 27, 2013 at 7:48 PM
I am trying to code a form on the front-end (rather than use the Admin). Here is some basic code:
public class QuoteLayoutForm : IFormProvider
        protected dynamic Shape { get; set; }
        public Localizer T { get; set; }

        public QuoteLayoutForm(
            IShapeFactory shapeFactory) {
            Shape = shapeFactory;
            T = NullLocalizer.Instance;

        public void Describe(DescribeContext context) {
            Func<IShapeFactory, object> form =
                shape => {

                    var f = Shape.Form(
                        Id: "MyLayout",
                        _BasicInformation: Shape.Fieldset(
                            Title: T("Basic Information"),
                            _Name: Shape.TextBox(
                                Id: "FirstName", Name: "First Name",
                                Title: T("First Name"),
                                Description: T("Enter your First Name")

                    return f;

            context.Form("MyLayout", form);
I was looking to have this show up in the front-end in two places in my module. I've got routes, etc. set up to do this from my module. First, I though I could do it from my controller:
        public ActionResult BasicInformation()
            var basicInformation = _shapeFactory.MyLayout();

            return new ShapeResult(this, basicInformation);
Which I knew wouldn't work because I don't have a View named "MyLayout.cshtml" (I got the error to this effect - i.e., that no shape with that name was found).

Second, I thought about trying to create a [Shape] class:
public class MyLayoutShape : IDependency
        public MyLayoutShape()
            T = NullLocalizer.Instance;

        public Localizer T { get; set; }

        public void MyLayout()
            //Not sure what would go here - I've looked through a bunch of code-samples but none gave me any ideas.

This allowed my page to be displayed, but it was empty (i.e. the form code didn't show up).

So my question is where I would "inject" this shape and how (i.e., can you point out a code example)? Thank you in advance for any help.

Jun 27, 2013 at 8:16 PM
Why don't you just create a MyLayout.cshtml view?
Jun 27, 2013 at 10:21 PM
I was trying that to see if the form I created would render. But I can't figure out how to do that. The view does show up if I just put some static text. But I tried doing something like @Model.MyLayout or @Model.MyLayout.FirstName. Didn't work.
Jun 28, 2013 at 2:31 AM
Edited Jun 28, 2013 at 2:35 AM
Still no luck after about 3 straight hours of trying. Can anyone in the know at least confirm whether or not you can use the Forms API to directly create a form in the front-end.

You can use custom forms to accomplish this, I know, but I am trying to code this. Custom Forms and the other examples only create a form with code in the Admin UI. Custom Forms uses a protected override DriverResult Display(. . .) { . . . }.

If I create a Driver then I have to create a Part, which is getting away from what I am trying to do an adding more complexity.

Many of the Admin UI examples I find do public void Describe (SomeClassContext describe) { . . . } when creating the form.

The only thing I can come up with is creating such a class, but that seems like overkill (not to mention beyond my skillset).

I appreciate any insight.