By pbland on
I'm trying to get a simple form to work in a custom module and I can't figure out what I'm doing wrong. I seem to be doing what every example I've found is doing, yet my _submit() either doesn't get called or doesn't work and I never see the message "FIRED!!!". Here is my code. I'd be grateful if someone could take a look and offer something.
<?php
// $Id$
function test_menu($may_cache) {
$items = array();
if ($may_cache) {
$items[] = array(
'path' => 'test',
'title' => t('View the form'),
'callback' => 'test_page',
'access' => TRUE
);
}
return $items;
}
function test_page() {
$output = t('This page contains our example form.');
$output .= drupal_get_form('test_nameform');
return $output;
}
function test_nameform() {
$form['user_name'] = array(
'#title' => t('Your Name'),
'#type' => 'textfield',
'#description' => t('Please enter your name.'),
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Submit'),
);
return $form;
}
function test_nameform_submit($form_id, $form_values) {
drupal_set_message(t("FIRED!!!"));
}
Comments
I also added a validate()
I also added a validate() method, but that is not getting triggered either. I don't see what I could be doing wrong.
=====================
UPDATE:
never mind, I didn't have
<?php if ($messages): print $messages; endif; ?>in my custom page.tpl.php.---------------------------------------------------------------
My drupal site: Vacation-Places