2015-04-01 97 views
1

我想创建在Drupal 7相似,它是在下面的链接什么形式:https://bmicalculator.cc/?gclid=CIrvnaXv1MQCFQwnjgodvWgAlQ如何在Drupal创建表单7

表应当与文本“BMI计算器”开始,然后在链接类似2列然后注意类似“BMI可能不准确的人...”

我知道一点Drupal表单Api,所以我可以创建窗体,但如何显示顶部的文本,如何创建2列的窗体然后再形成文字。

我是Drupal的新手,因此对drupal的工作原理没有深入的了解。

回答

2

要在顶部显示文本,请使用格式渲染数组中的#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. 
    ), 
    ), 
); 

希望这有助于。