A quick stab at a flowchart of the drupal_get_form() function. There are lots of subtleties that this glosses over, but it captures the overall progression.
Submitted by FGM (not verified) on October 1, 2006 - 12:23pm.
Thanks for the diagram. I think the Y/N choices are missing, though.
I tried to add them: you can recover the modified file from [[http://blog.riff.org/files/drupal_get_form.png]], and remove this comment afterwards (but check whether they are in the proper places !).
Submitted by Sal Peralta (not verified) on January 21, 2007 - 12:14pm.
I don't understand why the only options are to return the original form or do a redirect. How does one return data retrieved from a form query (i.e., use a form to do a search on content and return the results)?
For example, given a form that calls the following _submit function, how does one display the returned data?
function listing_basic_form_submit($form_id,$form_values) {
db_set_active('housing');
$city = $form_values['basic']['city'];
$low = $form_values['basic']['low'];
$high = $form_values['basic']['high'];
$sql_cnt = "SELECT COUNT(DISTINCT(id)) from residential where city='$city' AND low=$low AND high=$high";
$result = pager_query(db_rewrite_sql("SELECT id,city,ListPrice,area from residential where city='$city' AND low=$low AND high=$high"), 5,0,$sql_cnt);
db_set_active('default');
return $result;
}
This is were the #multistep mode for drupal's form handling comes in. To do what you're looking for, you would want to turn it into a #multistep form, turn #redirect off, and put the display of the search results into the form handling code itself. Check out this article on Lullabot.com for a very simple example.
Papirteksturer
—
Super-gorgeous high res paper textures in a language I don't understand.
jQTouch
—
A jQuery plugin for mobile web development on the iPhone, iPod Touch, and other forward-thinking devices.
SPECWEAPS
—
CLASSIFICATION SAPPHIRE VORPAL JULIET POTUS EYES ONLY .
freesound
—
A collaborative database of Creative Commons licensed sounds. Free foley in a box, browse-able by collection.
Opentape
—
A free way to make and host your own web mixtape. Simple, clean, effective.
Unlicense Yourself: Set Your Code Free
—
The Unlicense is a template for disclaiming copyright interest in software you've written; in other words, it is a template for dedicating your software to the public domain.
The Americanization of Mental Illness
—
"There is now good evidence to suggest that in the process of teaching the rest of the world to think like us, we’ve been exporting our Western 'symptom repertoire' as well."
In Defense of Lorem Ipsum
—
"Lorem Ipsum is one of those things like silicone breast implants or orange spray cheese in a can that just seems wrong..."
The New Cavemen Lifestyle
—
"Mr. Averbukh is a pre-Promethean sort of caveman. Much of his nourishment comes from grass-fed ground beef, which he eats raw. In a bow to the times, he sometimes uses a fork." Because vegan is way to bourgeois.
TufteGraph
—
Make pretty graphs with javascript, using jQuery. Supports slick tricks like stacked graphs with multipliers and other trimmings.
Missing Y/N
Thanks for the diagram. I think the Y/N choices are missing, though.
I tried to add them: you can recover the modified file from [[http://blog.riff.org/files/drupal_get_form.png]], and remove this comment afterwards (but check whether they are in the proper places !).
Updated -- thanks!
Yep, I realized I'd left ouy the y/n notations after posting it, but hadn't had a chance to update it.
A modified version of the chart should be hitting the Drupal.org handbook soon.
Using Drupal_get_form to return data?
I don't understand why the only options are to return the original form or do a redirect. How does one return data retrieved from a form query (i.e., use a form to do a search on content and return the results)?
For example, given a form that calls the following _submit function, how does one display the returned data?
function listing_basic_form_submit($form_id,$form_values) {
db_set_active('housing');
$city = $form_values['basic']['city'];
$low = $form_values['basic']['low'];
$high = $form_values['basic']['high'];
$sql_cnt = "SELECT COUNT(DISTINCT(id)) from residential where city='$city' AND low=$low AND high=$high";
$result = pager_query(db_rewrite_sql("SELECT id,city,ListPrice,area from residential where city='$city' AND low=$low AND high=$high"), 5,0,$sql_cnt);
db_set_active('default');
return $result;
}
#multistep
This is were the #multistep mode for drupal's form handling comes in. To do what you're looking for, you would want to turn it into a #multistep form, turn #redirect off, and put the display of the search results into the form handling code itself. Check out this article on Lullabot.com for a very simple example.
Thanks
Hey, that was really helpful. Thank you. Am I wrong in thinking that this was more difficult to do in DP 4.7 and earlier versions?
Nope, you're correct
It was indeed more difficult. It's certainly far from perfect now, but we're making iterative improvements...
Previous comment roughly
Previous comment roughly translates as "Is your hovercraft full of eels?"
Post new comment