我正在尝试设置一个由分层复选框组成的配置页面,如下所示:
-Parent#1
--option#1
--option#2
-Parent#2
--option#1
--option#2
为了实现上述布局,我使用以下代码:
$form['categories']['templates']['parent1'] = array(
'#type' => 'checkboxes',
'#title' => t('Select the appropriate actions for the form based on the indicated template'),
'#options' => array("Parent#1"),
'#multiple' => TRUE,
);
$form['categories']['templates']['parent1']['actions'] = array(
'#type' => 'checkboxes',
'#options' => array("P1 - option#1", "P1 - option#2"),
'#multiple' => TRUE,
);
$form['categories']['templates']['parent2'] = array(
'#type' => 'checkboxes',
'#title' => t('Select the appropriate actions for the form based on the indicated template'),
'#options' => array("Parent#2"),
'#multiple' => TRUE,
);
$form['categories']['templates']['parent2']['actions'] = array(
'#type' => 'checkboxes',
'#options' => array("P2 - option#1", "P2 - option#2"),
'#multiple' => TRUE,
);
但我得到的效果并不如预期。我附上了代码生成的图像: