[support] Form submit error - - - -Fatal error: Unsupported operand types

bharani kumar bharanikumariyerphp at gmail.com
Tue Oct 21 16:18:57 UTC 2008


my code :

<?php
function my_form($param1, $param2, $form_values = NULL) {
  // Build the fields that stay the same from form to form...

  $form['title'] = array(
    '#type' => 'textfield',
    '#title' => t('Quiz title'),
    '#required' => TRUE,
   '#default_value' => 'My quiz',
  );

  // The current number of questions, plus three more if
  // the user requested them.
  if (isset($form_values)) {
    $question_count = $form_values['question_count'];

    if ($form_values['op'] == t('More questions')) {
      $question_count = $question_count + 3;
    }
  }
  else {
    $question_count = 3;
  }

  $form['question_count'] = array(
    '#type' => 'hidden',
    '#value' => $question_count,
  );

  // We'll loop from 1 to n, where n is the current number of questions to
  // be displayed.

  for ($i = 1; $i <= $question_count; $i++) {
    $form['question_' . $i] = array(
      '#type' => 'textfield',
      '#title' => t('Question !count', array('!count' => $i)),
    );
  }

  // This part is important!
  $form['#multistep'] = TRUE;

  $form['more'] = array(
    '#type' => 'button',
    '#value' =>  t('More questions'),
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Submit'),
  );

  return $form;
}

function my_form_submit($form_id, $form_values) {

    for ($i = 1; $i <= $form_values['question_count']; $i++) {
      drupal_set_message($current_question = $form_values['question_' .
$i]);
      // Process $current_question
    }
    //return 'node/1'; // set redirect after submission, if desired
}

print drupal_get_form('my_form', 1, 2);
?>

When i run the site i got error like

*Fatal error*: Unsupported operand types in *C:\Program
Files\xampp\htdocs\cancom\includes\form.inc* on line *342

*--
Regards
B.S.Bharanikumar

POST YOUR OPINION
http://bharanikumariyer.hyperphp.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/support/attachments/20081021/d312e179/attachment.htm 


More information about the support mailing list