cfscript 组件内部
我正在为一个站点制作组件,我想知道是否可以从组件的返回变量中返回 cfform 并强制 Coldfusion 将其解析输出。
显然使用“writeOutput(”)”是行不通的。 我怎样才能做到这一点? 感谢您抽出时间!
I'm making components for a site and I'm wondering if I can return a cfform inside a return variable from a component and force coldfusion to output it parsed.
Obviously using "writeOutput(")" doesn't work.
How could I achieve this?
Thanks for your time!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您无法返回 cfform,因为标签不能在基于 CFScript 的组件内部使用。您最好使用自定义标签执行类似的操作,然后引用您的组件来获取构建表单的片段。
我会避免(如果可能的话)将任何 cfform 相关部分放入组件中,无论是否基于脚本。
如果您确实想最终走这条路,则需要将 cfform (及其相关部分)放在由基于脚本的组件调用的另一个组件中,或者放在随后保存到变量中的包含中。所有与尝试将 cfform 放入 CFC 相关的解决方案都会变得混乱。
You can't return a cfform, because tags can't be used inside of a CFScript based component. You're far better off doing something like this with a custom tag, which then references your component to get pieces to build out the form.
I would avoid (if at all possible) putting any cfform related pieces into a component, script-based or not.
If you did want to ultimately go this route, you'd need to put the cfform (and it's relevant pieces) either in another component that gets called by the script based one, or in an include that then is saved to a variable. All of the solutions related to trying to get the cfform into your CFC are going to be messy.
如果您绝对必须这样做(尽管我自己会回避它),您可能想看看这个:
http://www.madfellas.com/blog/index.cfm/2011/1/26/Using-CFML-tags -in-cfscript-C4X-原型
If you absolutely must do this (though I would shy away from it myself) you might want to have a look at this:
http://www.madfellas.com/blog/index.cfm/2011/1/26/Using-CFML-tags-in-cfscript-C4X-prototype