问题
I'm trying to use a wrapper view for fields in a custom form but when I do the wrapper content shows up fine but I lose my field. I've looked over this tutorial on placement and I'm trying to use the wrapper functionality to get separators into my custom form to break up the questions but it's not working.
For example I've got a question on my form that asks for Name. in my placement file I have the following
<!-- content:2.[section].[questionNumber] -->
<Place Fields_Common_Text_Edit-Name="Content:2.1.1"/>
<Place Fields_Input_Edit-PhoneNumber="Content:2.1.2"/>
...
And this works fine, but I want to put a series of seperator headers between certain groups/sections of questions, for example this one is "General Information"
So I change my placement file's line for the Name to this...
<Place Fields_Common_Text_Edit-Name="Content:2.1.1;Wrapper=GeneralInfoHeader"/>
<Place Fields_Input_Edit-PhoneNumber="Content:2.1.2"/>
And this works perfectly, my header shows up , but now my question for Name is gone and my first visible question is for Phone Number. According to the tutorial I used, my wrapper view looks like this
<h3>General Information</h3>
<hr>
@Model.Html
But the line of @Model.Html doesn't actually output my field. How do I get the wrapper to work for Fields? (Orchard 1.6)
回答1:
Well a wrapper is just a separate piece of Razor code that act like a parent of your view. So you need to tell them to display your content.
So you need to have @Display(Model.Metadata.ChildContent)
in your wrapper to display the field itself.
来源:https://stackoverflow.com/questions/14487005/orchard-wrappers-for-fields