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.

$output .= drupal_get_form('ahah_demo_simplest_form');
/**
* 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'],
    )
  ));
}


Comments

work77’s picture

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

WorldFallz’s picture

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

work77’s picture

Haha. At least I'm not alone.