我创建了自己的名为“cssswitch”的模块。我正在尝试创建自己的 html 布局来显示模块的管理表单部分。我了解如何使用 hook_form_alter() 来修改表单元素,但是我需要创建整个表单布局以使某些字段彼此相邻。看来我需要像我用theme_cssswitch_display()显示节点的前端视图的方式,但对于节点的管理部分。
function cssswitch_form_alter(&$form, $form_state, $form_id) {
switch($form_id) {
case 'cssswitch_node_form':
$form['hour_start']['#prefix'] = '<div class="start-box">';
$form['ampm_start']['#suffix'] = '</div>';
$form['ampm_start']['#attributes'] = array("style" => "border-width:2px;");
break;
}
}
function cssswitch_theme() {
return array(
'cssswitch_display' => array(
'arguments' => array('node'),
),
);
}
// to display the view of the node
function theme_cssswitch_display($node) {
$output = '<div class="cssswitch-cssfilename">Filename: '.
check_plain($node->cssfilename). '</div>';
$output .= '<div class="cssswitch-time_start">Start: '.
check_plain($node->hour_start). ':'.check_plain($node->minute_start).' '.check_plain($node->ampm_start).'</div>';
$output .= '<div class="cssswitch-time_end">End: '.
check_plain($node->hour_end). ':'.check_plain($node->minute_end).' '.check_plain($node->ampm_end).'</div>';
return $output;
}
谢谢你的帮助