在Drupal中创建具有单个自定义表单的多个CCK节点 [英] Create multiple CCK nodes with single custom form in Drupal

查看:138
本文介绍了在Drupal中创建具有单个自定义表单的多个CCK节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一个允许同时创建几个相关节点的表单。所有的节点都涉及到CCK字段。



我想尽可能多的使用CCK的内置验证,提交,输入小部件和安全功能。



Drupal 6中最好的方法是什么?在任何地方都有最佳做法或文档?



这里有3种可能性。



1。




  • 从内容类型为foo的标准节点创建表单开始。

  • 通过为内容类型栏添加字段来修改表单,使用hook form_alter [can cck widgets直接插入内容类型栏?]

  • 在提交表单时使用自定义提交处理程序创建类型栏的节点
    [可以调用标准的cck处理程序吗?或者我需要手动构造节点对象,进行自己的验证,并使用node_save?]



2。 h3>


  • 创建一个新的自定义表单,连接相关内容类型的正常节点创建表单。

  • <然后使用hook form_alter根据需要修改表单。
  • 允许标准的cck提交处理程序进行创建节点的工作。



3。




  • 从头开始创建自定义表单

  • 在我自己的提交处理程序中创建节点,使用节点准备,节点保存等。



如果发现关于重新使用标准节点创建表单的文档,但是创建多个节点同时没有提到。



使用hook nodeapi和hook form_alter记录在postom上的post e,但是特定的方法descrube似乎需要用'dummy'字段污染一个内容类型。



非常感谢您的帮助!

解决方案

这个advomatic的人发表了一个很好的解决方案。



http://www.advomatic.com/blogs/jonathan-delaigle/multiple节点 - 单节点提交


I need a form which will allow creation of several related nodes at the same time. All of the nodes involve CCK fields.

I would like to use as much of CCK's built-in validation, submission, input widget, and security functionality as possible/practical.

What is the best way to accomplish this in Drupal 6? Are there 'best practices' or docs anywhere?

Here are 3 possibilities I can see. I would love feedback on whether any of these would work, or if there are even better options.

1.

  • start with the standard node creation form for content type foo.
  • modify the form by adding fields for content type bar, using hook form_alter [can cck widgets for content type bar be inserted directly?]
  • use a custom submit handler to create node of type bar when the form is submitted [can the standard cck handler be called? or do i need to 'manually' construct the node object, do my own validation, and use node_save?]

2.

  • create a new, custom form that concatenates the 'normal' node creation forms for the relevant content types.
  • then use hook form_alter to modify the forms as necessary.
  • allow standard cck submit handlers to do the work of creating the nodes.

3.

  • create a custom form from scratch
  • create the nodes in my own submit handlers, using node prepare, node save, etc.

If found documentation on re-using the standard node creation form, but creating multiple nodes at the same time is not mentioned.

Using hook nodeapi and hook form_alter is documented in a post on advomatic's site, but the particular method descrube seems to require polluting one of the content types with 'dummy' fields.

Thank you very much for your help!

解决方案

The advomatic guys posted a nice solution to this.

http://www.advomatic.com/blogs/jonathan-delaigle/multiple-nodes-single-node-submission

这篇关于在Drupal中创建具有单个自定义表单的多个CCK节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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