hi

i tryed to migrate a module from 4.6 to 4.7. there are so many changes required by foram api... but ok, this seems to be done mostly.

but there is a different problem now. the $_POST['edit'] sometimes does not contain anything. the strange thing, it is filled with a array, build from the form, but if there is a "required" field not filled correctly i get the form back for correction. i i correct now the setting and then POST the form the $_POST['edit'] does not contain anything. i'm realy frustrated... 3 days and no success. what is wrong?

function test() {
       $prefix = 'example';
       $form['config'] = array(
             '#type' => 'fieldset',
             '#title' => t('Test selection'),
       );
       print "testA";
       if ($_POST['edit']) {
              print "testB";

//            does not work (whats wrong???)
              $p = $form_values[$prefix.'_test'];
              print_r ($p);

//            works well
              $p = $_POST['edit'][$prefix.'_test'];
              print_r ($p);
       } else {
              print "testC";
       }

       // blah blah code...

       return $form;
}

If i post this form the first time i get "testA" and "testB". If i repost the form after correcting a value i only get "testA" and never "testB".

PS: this is not the original code, it's an easier stripped example and i must understand...

Regards
Marc

Comments

Andrei Toutoukine’s picture

I have alike problem.

See flowchart at http://drupal.org/node/37194 for 4.7 forms API.

As far as I understood, after user-supplied form_submit() function is fired, all form data are cleaned before the new form displayed.

Like you I need to transfer some data from the submitted form to the page callback function. What I tried is a function with static variable which is either false or integer:

function get_current_form_page( $val=false, $change=false )
{
	static $page=false;
	if ( true=== $change ) {
		$page = $val;
	}
	return $page;
}

My module_page_callback() calls it with defaults, and first it receives 'false'.
Then it draws Form 1.

From my Form1_submit() it is called with integer and true arguments.

Next time when module_page_callback() is fired, I expected, that it will receive an integer and draw some Form2.

However I'm wrong. It receives false again. I have no idea how to manage this problem.

Multiple page forms are difficult! You could check also http://drupal.org/node/54753.