2011-05-20 63 views
2

我有一个名为field_testfield的cck字段我已经在.module文件中的形式中显示它,就像下面这样。
$form['field_testfield']['#weight'] = 10;
现在我想把它放在一个字段集中。对此有何想法?如何在字段集中放置一个cck字段?

+0

我已经在管理领域创建组做了的内容类型。但现在的问题是如何处理它的重量,因为它出现在表单的顶部,我想在表单的适当位置显示它? – Ahmad 2011-05-20 09:50:34

回答

1

实施的fieldsets正确的做法是

$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 
); 
+0

这很好,但它是在.module文件中的表单域。我有一个CCK字段,我在内容类型管理字段中创建。如何在fieldset中添加该字段?我是通过在内容类型的管理字段中创建一个组来完成的。 – Ahmad 2011-05-27 04:44:20