2013-10-30 63 views
1

我沒有收到我的表單中的任何提交按鈕。除了提交按鈕之外,所有東西都被渲染。我嘗試了很多東西,但顯然不是正確的,否則我不會在這裏。有人請指出我的愚蠢錯誤。Drupal 7,drupal_get_form不顯示提交按鈕

function output_string() { 
    $role_raw = current_path(); 
    $role_string = ucwords(str_replace('-', ' ', $role_raw)); 
    $output = '<div class=\"fishingnetwork\">You are not currently a member of <span class=\"rolestring\">' . $role_string . '</span> Network.'; 
    $output .= '<br>Would you like to join this network?</div><br>'; 

    return $output; 
} 

function mps_role_select_block_form($form, &$form_state) { 
    $form['network_role'] = array (
    '#type' => 'text', 
    '#title' => 'Role ID', 
    '#value' => 'myroleid' 
    ); 
    $form['submit'] = array(
    '#type' => 'submit', 
    '#value' => t('Yes') 
    ); 
} 

function mps_role_select_block_form_submit($form, &$form_state) { 
    rules_invoke_event('user_selecting_network', current_path()); 
} 


/** 
* Implementation of hook_block_info() 
*/ 


function mps_role_select_block_info() { 
    // This example comes from node.module. 
    $blocks['roleasking'] = array(
    'info' => t('Role Asking'), 
    'cache' => DRUPAL_NO_CACHE, 
); 

    return $blocks; 
} 


/** 
* Implementation of hook_block_view() 
*/ 

function mps_role_select_block_view($delta = '') { 
    // This example is adapted from node.module. 
    $block = array(); 

    switch ($delta) { 
    case 'roleasking': 
     $block['subject'] = t('Role Asking'); 
     $block['content'] = output_string() . drupal_render(drupal_get_form('mps_role_select_block_form')); 
     break; 

    } 
    return $block; 
} 
+1

您需要在表單函數中返回$ form;' – Clive

回答

1

在您的代碼中,您尚未返回表單。但假設這是一個複製粘貼問題,當您發佈的問題 既然你說「$形式[‘network_role’]」也變爲

下面的東西可能是一個問題,從形式 1)返回$形式。如果你這樣做,請執行以下操作。 2)打印(使用print_r()函數)並參閱「drupal_render(drupal_get_form('mps_role_select_block_form'))」如果它具有sumbit按鈕的html。 3)如果提交按鈕的數組由drupal_get_form('mps_role_select_block_form')返回並且不呈現,則返回true。 如果您使用自定義主題,則可能是主題中的問題。