2015-04-01 89 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. 
    ), 
    ), 
); 

希望這有助於。