【问题标题】:How to place a cck field inside a fieldset?如何在字段集中放置一个 cck 字段?
【发布时间】:2011-05-20 06:31:45
【问题描述】:

我有一个名为 field_testfield 的 cck 字段,我已经在 .module 文件中以如下形式显示它。
$form['field_testfield']['#weight'] = 10;
现在我想将它包含在一个字段集中。有什么想法吗?

【问题讨论】:

  • 我已经通过在内容类型的管理字段中创建组来完成它。但现在的问题是如何处理它的重量,因为它出现在表单的顶部,我想将它显示在表单中的适当位置?

标签: drupal-6 cck fieldset


【解决方案1】:

实现字段集的正确方法是

$form['my_fieldset'] = array(
  '#type' => 'fieldset',
  '#weight' => 0,
  '#collapsible' => TRUE, //is the fieldset collabsible?
  '#collapsed' => TRUE //is the fieldset collabsped at start?
);

要在此字段集中添加字段,您需要将元素附加到字段集数组

$form['my_fieldset']['custom_field_1'] = array(
  '#type' => 'textarea', //or whatever
  '#weight' => 0 //the weight set here is the weight of the element inside the fieldset
);

【讨论】:

  • 这很好,但它适用于 .module 文件中的表单字段。我有一个 CCK 字段,我在内容类型管理字段中创建。如何在字段集中添加该字段?我通过在内容类型的管理字段中创建一个组来做到这一点。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-03-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多