以非 CCK Drupal 形式“添加另一个项目" [英] 'add another item' in non-CCK Drupal forms

查看:22
本文介绍了以非 CCK Drupal 形式“添加另一个项目"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Drupal 的 CCK 有一个方便的特性,允许单个 CCK 字段通过添加另一个项目"按钮接受多个值,从而在节点中生成数据数组.

CCK for Drupal has the handy feature of allowing a single CCK field to accept multiple values via a "add another item" button that results in an array of data in the node.

我想知道是否有任何简单的方法可以将其调整为我将通过 drupal_get_form 调用的非 CCK 表单.我宁愿不必用多步表单技术重新发明轮子.

I'm wondering if there's any easy way of adapting this for a non-CCK form that I'd be calling by drupal_get_form. I'd rather not have to re-invent the wheel with multi-step form techniques.

有人这样做过吗?

推荐答案

如果他们包含一个更精简的示例就好了,但是 这篇 Drupal 中的 AHAH 简介,以及 这篇关于使用添加动态表单元素的帖子啊哈 应该几乎涵盖了您需要的所有内容(不幸的是,这相当多).

It would be nice if they had included a more reduced example, but this Introduction to AHAH in Drupal, along with this post on adding dynamic form elements using AHAH should cover pretty much all you need (which, unfortunately, is quite a bit).

CCK 这样做的方式(主要是在 content.node_form.inc 中的 content_add_more_js())有点复杂,因为它们需要满足不同字段类型的泛化,以及添加一些额外的东西以实现平滑的 tablesort 拖放功能.所以除非你需要后者,否则我不想用它作为例子,因为它有点令人困惑;)

The way CCK does this (mainly in content_add_more_js() in content.node_form.inc) is a bit more convoluted, as they need to cater for the generalization for different field types, as well as adding some extra stuff to allow for smooth tablesort Drag&Drop functionality. So unless you need the latter, I'd rather not use it as an example, as it gets a bit confusing ;)

这篇关于以非 CCK Drupal 形式“添加另一个项目"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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