要在顶部显示文本,请使用表单渲染数组中的#markup 项。然后,您可以在此标记中嵌入您需要的 html。
对于这两列,在表单渲染数组中使用#container 类型。这允许您将<div> 包裹在子元素周围。然后,您可以根据需要浮动 div。
所以一个例子是
$form = array(
/*
* ... form header info here
*/
'header' => array(
'#markup'=>'<h1> BMI Calc </h1>',
),
'col1'=>array(
'#type'=>'container',
'subitemA'=>array(
//some stuff
),
'subitemB'=>array(
//some stuff
),
'#attributes' => array(
'class' => array('class-name'), //use css to float left
//alternatively float left using style in this area
),
),
'col2'=>array(
'#type'=>'container',
'subitemA'=>array(
//some stuff
),
'subitemB'=>array(
//some stuff
),
'#attributes' => array(
'class' => array('class-name'), //use css to float left
//alternatively float left using style in this area
//NOTE: still float left, the divs will align as two columns unless
//screen space is too small, then it will stack responsively.
),
),
);
希望这会有所帮助。