Is there any up to date information anywhere on the forms API for 5.1? There's loads of stuff about forms scattered around drupal.org, but it all is either dated, contradictory or just plain wrong. I'm having hell of a time working out how all this forms stuff works!
Most searches lead here:
http://api.drupal.org/api/HEAD/file/developer/topics/forms_api.html
but the code on that page described as "a working piece of code" crashes PHP on my machine! Actually, the line at the bottom:
$output = drupal_get_form('test_page', $form);
seems to call the test_page() function recursively, which causes PHP to abort or something. Also, what's that second parameter? The API docs don't describe what it's doing, and the example code doesn't even take a parameter. I can't even see what it's trying to do.
Floundering around by myself, I discovered that this seems closer to a starting point:
function example_form1()
{
$form['field_2'] = array(
'#type' => 'submit',
'value' => t('Submit')
);
return $form;
}
function testForm()
{
$content = drupal_get_form('example_form1');
print theme( 'page', $content );
}
only since I missed the '#' from the '#value' array element, this also causes PHP to bomb out, this time with a memory leak.