Hi,
I want to test a simple form with some voting buttons.

I created a module called voteForm.module (code below) and voteForm.info.
I can successfully "enable" it in the admin->modules.

After that I get the following error:

warning: Cannot modify header information - headers already sent by (output started at /home/userc/public_html/sites/all/modules/voteForm/voteForm.module:57) in /home/brajeshc/public_html/includes/common.inc on line 311.

Can anyone see what I am doing wrong? thank you!

// $Id$ 
/** 
 * @file 
 * Lets me make a voting form 
 * 
 * This is a module to make a voting form.
 * This module will be used as a template. 
 */ 

function voteForm_menu($maycache) {
  if ($maycache) {
    $items[] = array(
      'path' => 'voteForm',
      'type' => MENU_CALLBACK,
      'callback' => 'drupal_get_form',
      'callback arguments' => array('voteForm_form'), 
    );
    return $items;
  }
}


function voteForm_form() {

$form['voteForm'] = array( 
    '#type' => 'radios', 
    '#title' => t('Your votes'), 
    '#description' => t('A voting form template'), 
    '#options' => array( 
      t('like it'), 
      t('dont care'), 
      t('do not like it') 
    ), 
    '#default_value' => 0 // default to Never 
  );

  return $form;
}

/**
* Validate submitted values. Note: form_id_validate.
*/
function voteForm_form_validate($form_id, $form_values) {
 drupal_set_mesage(t('You made it to the validate function!'));
}

/**
* Process submission. Note: form_id_submit.
*/
function voteForm_form_submit($form_id, $form_values) {
  drupal_set_mesage(t('you made it to the submit function!')); 
}

Comments

jadelrab’s picture

Well you have an empty line after the closing ?> it is always recommended to not close your module with ?>
that is what it causes the warning ..

and in your code the default value for options in the form default to the first option (i like it) not to never because it will take the key 0 which is set in the default value ..

you still miss the submit button to submit the form ..

Best Regards,
Mohamed Jadelrab

mrbkonline’s picture

I removed the ?> and things are working!
thank you!