简体   繁体   中英

Drupal 7, drupal_get_form not displaying submit button

I'm not getting any submit button in my form. Everything is being rendered except the submit button. I have tried many things, but obviously not the right one or I wouldn't be here. Someone please point out my stupid error.

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

In your code you have not returned your form. But assuming this is a copy paste issue when you posted the question since you say "$form['network_role']" is also rendered

Following things could be a problem 1)return $form from form. if you are doing that, do the following.

2)Print (using print_r() function) and see "drupal_render(drupal_get_form('mps_role_select_block_form'))" if it has sumbit button's html.

3)if it submit button's array is returned by drupal_get_form('mps_role_select_block_form') and not rendered. It could be a problem in theming if you are using a custom theme.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM