[support] FAPI and "returned" page

Metzler, David metzlerd at evergreen.edu
Wed Feb 6 16:26:37 UTC 2008


---
Yes this is correct.  Submit and validate fire before any form rendering
is done.  It's not perfect but it's what is there. Part of the rational
for doing this is that if you return path from a submit handler drupal
will redirect to that page.  

If you want to multiply the contents of two fields you are going to do
it like this: 

1.  IN the submit handler modify the data that your application is based
on, using session variables or some other permanent data store (the
database is most common) and alter data. 

2.  Reference these structures in the form rendering function to display
the data.  

function test_form()
{
	$form['value1'] = array('#type' => 'textfield',
	   '#title' => 'Value 1',
	   '#default_value' => '3',
    ); 
    
    $form['value2'] = array('#type' => 'textfield',
       '#title' => 'Value 1',
       '#default_value' => '3',
    ); 
    
	$form['total'] = array('#type' => 'item',
	   '#title' => 'Total',
	   '#value' => $_SESSION['mymodule']['total'],
	); 
	
	$form['submit'] = array(
	  '#type' => 'submit',
	  '#value' => 'multiply', 
	 ); 
	  
   return $form;   
}

function test_form_submit($formid, $form_values)
{
	
	$_SESSION['mymodule']['total'] = $form_values['value1'] *
$form_values['value2'];
     

}

-----Original Message-----
From: support-bounces at drupal.org [mailto:support-bounces at drupal.org] On
Behalf Of Ivan Sergio Borgonovo
Sent: Wednesday, February 06, 2008 5:15 AM
To: support at drupal.org
Subject: [support] FAPI and "returned" page

_submit and _validate get the form in a ordinate way... but they don't
output anything on screen.


Suppose I want to do something as stupid as multiplying 2 fields and
return the output on screen without having to save the 2 fields
somewhere... as if _submit was not going to return a path but just
use $form_values in spite of $_POST and output something...

I gave a look at how search works and at a quick glance it looks not
suited.
Up to my understanding it parse keys and then _submit append it to a
url.

thanks

-- 
Ivan Sergio Borgonovo
http://www.webthatworks.it

-- 
[ Drupal support list | http://lists.drupal.org/ ]


More information about the support mailing list