Use LayoutSelector Part with Custom Form?

Topics: General
Nov 5, 2013 at 5:56 PM
Edited Nov 5, 2013 at 5:57 PM
I wanted to select one of my other layouts (rather than the default) to display the custom form I created. I tried to attach the Layout Selector part to the Custom Form type (not the form type that I created) and can see it when I go to my custom form. However, when I load the actual page it does not use the layout I selected.

Any thoughts?
Nov 5, 2013 at 7:17 PM
Edited Nov 5, 2013 at 7:19 PM
I don't think this is possible, so I am thinking of another method of customizing the way custom forms display. Can anyone bear this out or advise me on how to specifically display a field (a question I elaborate on below).

I am creating a Content.Edit-MyForm.cshtml view in my Theme. I can create some specific zones in there and use placement to handle how the form looks, thusly:

View:
<div class="edit-item">
    <div class="edit-item-primary">
        @if (Model.Content != null) 
        {
            <div class="edit-item-content">
                <div class="first-zone">
                    @Display(Model.MyFirstZone)
                </div>
                <div class="second-zone">
                    @Display(Model.MySecondZone)
                </div>
            </div>
        }
    </div>
    ....
</div>
Placement:
<Match ContentType="MyForm">
    <Place Fields_Input_Edit-FirstField="MyFirstZone:1"/>
    <Place Fields_Input_Edit-SecondField="MySecondZone:1"/>
</Match>
I am wondering, however, if there is a cleaner/simpler way of just inserting the fields I created in my Custom Form rather than doing it this way?

Essentially, is there a way I can just place the actual field in the view? I ask because I would have to create a zone for each field in terms of the way I want it to display and then create the corresponding placement, which is a little redundant.

Thanks.
Nov 5, 2013 at 8:25 PM
I spent a lot of time trying to figure out exactly what you're asking. The solution you suggested above (which was posted as one answer at StackOverflow) was the best I could find that didn't require too much in terms of modifying. Ultimately, it was the most straightforward method. I just had to dig around the internet for how to indicate the other field types in the placement file (boolean, enumeration, etc.).

I was able to place each field individually using the above. A bit tedious at first, but I like the end result (i.e., an almost completely fully-customized custom form layout).
Nov 5, 2013 at 9:38 PM
Thanks. Sorry I didn't credit the code above - I had forgotten where I'd gotten it from.

Looks like this is the only way to go.