"Hello World" script for Drupal forms displays nothing

work77 - October 21, 2009 - 19:03

I got this helloWorld code for drupal forms from http://randyfay.com/node/27
When it loads, there is no form. PHP input is allowed for this content type. Does a new module need to be created for this to work?
Any suggestions? Thanks.

<?php
$output
.= drupal_get_form('ahah_demo_simplest_form');
?>

<?php
/**
* A Hello-world for Forms API (FAPI)
*/
function ahah_demo_simplest_form() {

 
$form['explanation'] = array(
   
'#type' => 'markup',
   
'#value' => '<div>' . t('This is a basic form with just a bit of information') . '</div>',
  );

 
$form['experience'] = array(
   
'#type' => 'select',
   
'#title' => t('What is your experience level in Drupal?'),
   
'#options' => array(
     
'expert' => t('Expert'),
     
'journeyman' => t('Journeyman'),
     
'beginner' => t('Beginner')),
  );
 
$form['more'] = array(
   
'#type' => 'textfield',
   
'#title' => t("Say more about yourself"),
   
'#description' => t('Surely one word can\'t describe you.'),
  );
 
$form['submit'] = array(
   
'#type' => 'submit',
   
'#value' => t('Click Me'),
  );

  return
$form;
}


function
ahah_demo_simplest_form_submit($form, &$form_state) {
 
drupal_set_message(t('You have claimed to be %experience: %more',
    array(
     
'%experience'=>$form_state['values']['experience'],
     
'%more' => $form_state['values']['more'],
    )
  ));
}
?>

doh!

work77 - October 21, 2009 - 19:10

Never mind. Forgot to echo the $output. :)

_

WorldFallz - October 21, 2009 - 20:04

omg-- l've lost count of how much time I've wasted troubleshooting something for this exact reason, lol.

_
Don't be a Help Vampire - read and abide the forum guidelines.
If you find my assistance useful, please pay it forward to your fellow drupalers.

-

work77 - October 26, 2009 - 16:35

Haha. At least I'm not alone.

 
 

Drupal is a registered trademark of Dries Buytaert.