Coldfusion Mura在页面中显示表单数据

Coldfusion Mura在页面中显示表单数据,coldfusion,lucee,mura,Coldfusion,Lucee,Mura,我有一些自定义html代码,我需要从我在mura后端创建的表单中获取名称和图像以及标题,我如何做到这一点,我在google组中搜索了所有地方,但没有找到任何相关内容,我只需要开始做什么,如何找到保存的数据,对于cfoutput,我认为我需要进行迭代 <cfset it = $.getBean('content').loadBy(title='myform')> <cfdump var="#it#"> <cfif it.hasNext()>

我有一些自定义html代码,我需要从我在mura后端创建的表单中获取名称和图像以及标题,我如何做到这一点,我在google组中搜索了所有地方,但没有找到任何相关内容,我只需要开始做什么,如何找到保存的数据,对于cfoutput,我认为我需要进行迭代

<cfset it = $.getBean('content').loadBy(title='myform')>
    <cfdump var="#it#">
    <cfif it.hasNext()>
  <ul>
    <cfloop condition="it.hasNext()">
      <cfset item = it.next()>
      <li>
        #esapiEncode('html', item.get('name'))#
      </li>
    </cfloop>
  </ul>

  • #esapiEncode('html',item.get('name'))#

我需要获取表单并按上面的ul>li格式显示数据,但它给我的错误是hasnext()未定义,这在某种程度上是有意义的,但我不确定我在这里缺少了什么。我可以用MURA CMS 7.1和form builder确认这是可行的

ContentID:

重要的部分是通过“ContentID”引用表单,您可以在“表单生成器->表单->高级”部分找到它

变量引用:

此外,还需要分别更改对“formContentId”和“wddxImageFieldName”的引用

设置:

要测试这一点,只需将其放入您的RectiveThemes模板中,并确保您至少提交了一次表单

基于Steve Withington的代码,网址:


rsData=QueryNew(“”);
dcm=$.getBean('dataCollectionManager');
formContentId='856499BD-01E2-48C9-CD1A0430D859E81B';
wddxImageFieldName=‘化身_附件’;
formBean=$.getBean('content').loadBy(contentID=formContentId);
如果(!formBean.getIsNew()){
currentFieldList=dcm.getCurrentFieldList(formBean.getContentID());
数据={
sortby='已输入'
,sortdirection='desc'
,关键字=“”
,siteid=$。事件('siteid')
,contentid=formBean.getContentID()
};
rsData=dcm.getData(数据);
}
很抱歉,该表单不存在,或者尚未提交任何记录。
输入的日期/时间
#esapiEncode('html',字段名)#
#进入#
#记录[字段名]#

@Habb我想这可能会对你有所帮助。它已经过全面测试,所以如果它不适合你,这可能意味着你的MURA CMS版本有一个bug…我在MURA 7.0上,但我会测试它,看看它是如何运行的performs@Habb我希望它对你有用。如果没有,那么将内核更新到7.1应该是相当轻松的。
<cfscript>
  rsData = QueryNew('');
  dcm = $.getBean('dataCollectionManager');
  formContentId = '856499BD-01E2-48C9-CD1A0430D859E81B';
  wddxImageFieldName = 'AVATAR_ATTACHMENT';
</cfscript>

<cfif !Len($.event('responseid'))>
  <!--- All Form Submission Results --->
  <cfscript>
      formBean = $.getBean('content').loadBy(contentID=formContentId);
      if ( !formBean.getIsNew() ) {
          currentFieldList = dcm.getCurrentFieldList(formBean.getContentID());
          data = {
              sortby = 'entered'
              ,sortdirection = 'desc'
              ,keywords = ''
              ,siteid = $.event('siteid')
              ,contentid = formBean.getContentID()
          };
          rsData = dcm.getData(data);
      }
  </cfscript>
  <cfif !rsData.recordcount>
    <h3>Sorry, either the form does not exist, or no records have been submitted yet.</h3>
  <cfelse>
    <table cellspacing="5" cellpadding="5" border="1">
      <!--- FieldNames --->
      <thead>
          <tr>
            <th>&nbsp;</th>
            <th>Date/Time Entered</th>
            <cfloop list="#currentFieldList#" index="fieldName">
              <th>#esapiEncode('html', fieldName)#</th>
            </cfloop>
          </tr>
      </thead>
      <!--- Actual Output --->
      <tbody>
        <cfloop query="rsData">
            <tr>
              <!--- Edit --->
              <td>
                  <a href="./?responseid=#responseid#">Edit</a>
              </td>
              <!--- The Date/Time Stamp --->
              <td>
                  #entered#
              </td>
              <!--- The Data --->
              <!--- Forms are stored as WDDX files ... so we need to unpack them --->
              <cfwddx action="wddx2cfml" input="#data#" output="record" />
              <cfloop list="#currentFieldList#" index="fieldName">
                <td>
                  <cfif StructKeyExists(record, fieldName)>
                    #record[fieldName]#
                    <cfif CompareNoCase(fieldName,wddxImageFieldName) EQ 0>
                      <img src="#$.getURLForImage(record[fieldName])#">
                    </cfif>
                  <cfelse>
                    &nbsp;
                  </cfif>
                </td>
              </cfloop>
            </tr>
        </cfloop>
      </tbody>
    </table>
  </cfif>
</cfif>