我有一个名为field_testfield的cck字段我在.module文件中的表单中显示了它,如下所示。
$form['field_testfield']['#weight'] = 10;
现在我想把它放在一个fieldset中。有什么想法吗?
答案 0 :(得分: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
);