果园-田地包装纸 [英] Orchard - Wrappers for Fields

查看:95
本文介绍了果园-田地包装纸的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图对自定义表单中的字段使用包装视图,但是当我这样做时,包装内容显示得很好,但是我丢失了字段.我已经查看了关于放置的本教程,我正在尝试使用包装器功能,可以将分隔符放入我的自定义表单中,以分解问题,但无法正常工作.

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

但是@ Model.Html的行实际上并不输出我的字段.如何使包装器适用于Fields? (果园1.6)

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)

推荐答案

好,包装器只是单独的一部分Razor代码,其作用类似于视图的父级.因此,您需要告诉他们显示您的内容.

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.

因此,您需要在包装中包含@Display(Model.Metadata.ChildContent)才能显示字段本身.

So you need to have @Display(Model.Metadata.ChildContent) in your wrapper to display the field itself.

这篇关于果园-田地包装纸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆