2011-12-23 98 views
0

我試圖在drupal中創建節點/內容類型,因此我至少有一個.info,.install和.module文件。窗體不顯示爲Drupal 7中的節點/內容類型

該模塊創建正常,我可以從模塊管理頁面啓用/禁用它,同樣,Drupal能夠將此模塊識別爲內容類型,並在點擊內容中的「添加內容」時出現菜單。

一切工作正常,但它並不顯示錶單元素,而是直接在enter image description here

開始的表單元素代碼如下:

function newNode_form($node,&$form_state) 
{ 
$type = node_get_types('type',$node); 

$form['title']= array( 
    '#type' => 'textfield', 
    '#title' => check_plain($type->title_label), 
    '#default_value' => !empty($node->title) ? $node->title : '', 
    '#required' => TRUE, 
    '#weight' => -5, 
); 

    $form['field1'] = array( 
    '#type' => 'textfield', 
    '#title' => t('Custom field'), 
    '#default_value' => $node->field1, 
    '#maxlength' => 127, 
); 
    $form['selectbox'] = array( 
    '#type' => 'select', 
    '#title' => t('Select box'), 
    '#default_value' => $node->selectbox, 
    '#options' => array( 
     1 => 'Option A', 
     2 => 'Option B', 
     3 => 'Option C', 
    ), 
    '#description' => t('Choose an option.'), 
); 
return $form; 
} 

可有人告訴我,什麼是錯的

PS:Just FYI:在我的.install文件中,只存在安裝和卸載掛鉤功能。我還沒有創建數據庫表,這種內容類型是我創建內容類型用戶界面的演練,並不一定是完整的用戶界面。

回答

0

Drupal的鉤子系統使用小寫和低於分數來動態加載模塊函數。

<module name>_<hook_name> 

嘗試聲明你的函數是這樣的:

function new_node_form($node, &$form_state) { 
... 
+0

是啊,但你的回答不正確,感謝您的幫助,我想它了。模塊的名稱是newNode,因此獲取new_node命名術語不是解決方案。答案是這是Pre-Drupal 7策略,而不是Drupal 7安裝節點的方式。感謝您的幫助。 – 2011-12-26 19:56:22