I am trying to develop a simple module for taking information from a form, then emailing it to a specified address. I was able to get the module to show under the admin section and it displays the link in the menu, but when I try to access the form, the page simply says "Array'.

What am I doing wrong?

<?php 
// $Id$

/**
* @file
*  
* Additional notes
* 
* 
* 
*/

function voicet1quote_menu($may_cache) {
  
  $access = user_access('request quote');
  
    $items[] = array(
	  'path' => 'products/telecommunications/requestvoicet1quote',
	  'title' => t('Request Voice T1 Quote'),
	  'callback' => voicet1quote_form,
	  'access' => TRUE
	);

return $items;

}


function voicet1quote_form() {

  $form = array();

  $circuitoptions = array('t' => t('T1'), 'p' => t('PRI'), 'a' => t('Analog'), 'u' => t('Unknown'));
  
  $form['contact'] = array(
  '#type' => 'fieldset',
  '#title' => t('Contact and Site Information'),
  '#tree' => TRUE,
  );

  $form['contact']['name'] = array(
  '#type' => 'textfield',
  '#size' => 24,
  '#title' => t('Name'),
  );

  $form['contact']['email'] = array(
  '#type' => 'textfield',
  '#size' => 128,
  '#title' => t('Email Address'),
  );
  
  $form['contact']['address1'] = array(
  '#type' => 'textfield',
  '#size' => 128,
  '#title' => t('Address 1'),
  );
  
  $form['contact']['address2'] = array(
  '#type' => 'textfield',
  '#size' => 32,
  '#title' => t('Address 2'),
  );
  
  $form['contact']['city'] = array(
  '#type' => 'textfield',
  '#size' => 32,
  '#title' => t('City'),
  );
  
  $form['contact']['state'] = array(
  '#type' => 'textfield',
  '#size' => 2,
  '#title' => t('State'),
  );
  
  $form['contact']['zip'] = array(
  '#type' => 'textfield',
  '#size' => 16,
  '#title' => t('Zip'),
  );
  
  $form['quote'] = array(
  '#type' => 'fieldset',
  '#title' => t('Quote Information'),
  '#tree' => TRUE,
  );
  
  $form['quote']['lines'] = array(
  '#type' => 'textfield',
  '#size' => 3,
  '#title' => t('Number of Lines Needed'),
  );
  
  $form['quote']['circuitoptions'] = array(
  '#type' => 'radios',
  '#title' => t('Type of Lines Needed'),
  '#default_value' =>  variable_get('circuitoptions', 't'),
  '#options' => $circuitoptions,
  );
  
  $form['quote']['dlongdistance'] = array(
  '#type' => 'checkbox',
  '#title' => t('We have domestic long distance needs'),
  '#default_value' => variable_get('dlongdistance', 0),
  );
  
  $form['quote']['ilongdistance'] = array(
  '#type' => 'checkbox',
  '#title' => t('We have international long distance needs'),
  '#default_value' => variable_get('ilongdistance', 0),
  );
  
  $form['quote']['existing'] = array(
  '#type' => 'checkbox',
  '#title' => t('We have existing service through another provider'),
  '#default_value' => variable_get('existing', 0),
  );
  
  $form['quote']['pname'] = array(
  '#type' => 'textfield',
  '#size' => 32,
  '#title' => t('Provider Name'),
  );
  
  $form['quote']['payment'] = array(
  '#type' => 'textfield',
  '#size' => 32,
  '#title' => t('Estimated Monthly Payment'),
  );
  
  $form['quote']['details'] = array(
  '#type' => 'textarea',
  '#title' => t('Additional Details'),
  '#cols' => 60,
  '#rows' => 8,
  );

  $form['submit'] = array('#type' => 'submit', '#value' => t('Request Quote'));

  return drupal_get_form('voicet1quote_form', $form);
}


function voicet1quote_form_validate($form_id, $form_values) {

  if ( !isset($form_values['contact']['name']) ) {
    form_set_error('name', t('Please specify your name.'));
  }
   
  if ( !isset($form_values['contact']['email']) ) {
    form_set_error('email', t('Please specify your email address.'));
  }

  if ( !isset($form_values['contact']['address1']) ) {
    form_set_error('address1', t('Please specify your mailing address.'));
  }

  if ( !isset($form_values['contact']['city']) ) {
    form_set_error('city', t('Please specify your city.'));
  }

  if ( !isset($form_values['contact']['state']) ) {
    form_set_error('state', t('Please specify your state.'));
  }

  if ( !isset($form_values['quote']['existing']) ) {
    if ( !isset($form_values['quote']['pname']) ) {
      form_set_error('pname', t('Please specify the existing provider name.'));
    }
	else if ( !is_numeric($form_values['quote']['payment']) ) {
	  form_set_error('payment', t('Monthly payment must be inn numeric form.'));
	}
  }

  if ( !isset($form_values['quote']['existing']) ) {
    form_set_error('zip', t('Please specify your zip code.'));
  }

  if ( !isset($form_values['quote']['lines']) ) {
    form_set_error('lines', t('Please specify the number of lines you need.'));
  }

  else if ( !is_numeric($form_values['quote']['lines']) ) {
        form_set_error('lines', t('The number of lines must be in numeric form.'));
  }

}

function voicet1quote_form_submit($form_id, $form_values) {  
  
//SEND OUT EMAIL------------------------------------------------------------------------------------------------
  
  $output  = 'products/telecommunications/requestvoicet1quote/results/';
  
  return $output;

}

function voicet1quotesubmit() {

  $output = "Your quote has been submitted.";
  
  return $output;

}

    
?>

Comments

panis’s picture

change the menu code to:

    $items[] = array(
      'path' => 'products/telecommunications/requestvoicet1quote',
      'title' => t('Request Voice T1 Quote'),
      'callback' => drupal_get_form,
      'callback arguments' => array('voicet1quote_form'),
      'access' => TRUE
    );

And replace the last line of your form function voicet1quote_form() with

return $form;

instead of

return drupal_get_form(...)

You cannot easily combine the form definition and rendering as you have done in a single function.

mediumgrade’s picture

That's it! Thanks!