Styling Custom Form

Topics: Customizing Orchard
Editor
Apr 5, 2013 at 1:51 PM
I am trying to style the Submit button of the Custom Form module in Orchard 1.6 and have a question.

Using Shape Tracer, there is no alternate showing up for it. It doesn't really indicate where it is coming from. After inspecting the Module I found a template called Parts.CustomForm.Wrapper.cshtml that looks what I shouuld add to my theme, but this is not working. I ended up looking in the "Item" folder of the module and found the Create.cshtml file which also has the submit button. I placed this in my theme and was able to override it with custom text/classes.

I would like to be able to use Parts.CustomForm.Wrapper.cshtml though. When does this get used? The Display driver indicates it is being called, but it seems like it is not. I need to re-organize where the button appears and I need to do it in the wrapper.
Developer
Apr 6, 2013 at 3:55 PM
You should be able to copy over the Parts.CustomForm.Wrapper.cshtml file to your theme and modify it. You could even remove the button from it and add it to your custom form template if you wanted to.
Editor
Apr 6, 2013 at 3:57 PM
I tried that, but my changes were not taking effect. Seems the template was not getting hit.
Developer
Apr 6, 2013 at 4:00 PM
That's weird, I tried and it works.
May 27, 2013 at 9:04 PM
There is a problem in fact.

For the first time Parts.Customform.Wrapper.cshtml is displayed ... but if you make an error. For example leave empty input text area if it is required. Then view from ItemController is displayed and it looks like this.
@using Orchard.ContentManagement
@{
    ContentItem customForm = Model.ContentItem;
    string returnUrl = Model.ReturnUrl;

    // remove default Save/Publish buttons
    Model.Zones["Sidebar"].Items.Clear();
}

@using (Html.BeginFormAntiForgeryPost(returnUrl)) {
    @Html.ValidationSummary()
    // Model is a Shape, calling Display() so that it is rendered using the most specific template for its Shape type
    @Display(Model)

    <fieldset class="submit-button">
        <button type="submit" name="submit.Save" value="submit.Save">@T("Submit")</button>
    </fieldset>
}
And submit button doesn't works like shape
May 27, 2013 at 9:36 PM
I think I've found a solution

Change View/Item/Create.cshtml in CustomForms like this
@using Orchard.ContentManagement
@{
    ContentItem customForm = Model.ContentItem;
    string returnUrl = Model.ReturnUrl;

    // remove default Save/Publish buttons
    Model.Zones["Sidebar"].Items.Clear();
    Model.Zones["Content"].Add(New.Content_SaveButton().ContentItem(customForm), "25");
}

@using (Html.BeginFormAntiForgeryPost(returnUrl)) {
    @Html.ValidationSummary()
    // Model is a Shape, calling Display() so that it is rendered using the most specific template for its Shape type
    @Display(Model)
}
Now you can override Content.SaveButton in theme