1

我的表单中没有任何提交按钮。除了提交按钮之外,一切都在呈现。我尝试了很多事情,但显然不是正确的,否则我不会在这里。有人请指出我的愚蠢错误。

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;
}
4

1 回答 1

1

在您的代码中,您没有返回您的表格。但是假设这是您发布问题时的复制粘贴问题,因为您说“$form ['network_role']”也被渲染

以下事情可能是一个问题 1)从表单返回 $form。如果您正在这样做,请执行以下操作。

2)打印(使用 print_r() 函数)并查看“drupal_render(drupal_get_form('mps_role_select_block_form'))”,如果它有 sumbit 按钮的 html。

3) 如果提交按钮的数组由 drupal_get_form('mps_role_select_block_form') 返回且未呈现。如果您使用自定义主题,主题可能会出现问题。

于 2013-10-31T06:22:49.583 回答