warning: Missing argument 1 for formexample_menu()

AuctionTeamster - July 22, 2008 - 05:21

I am new to Drupal and am finding the learning curve to be extensive at this juncture. Created example for testing and learning purposes. The modules has been created and enabled. When attempting to view the page www.barlowauctions.com/?q=formexample it returns page not found. As well the admin page provides this warning:

warning: Missing argument 1 for formexample_menu() in /home/barlowau/public_html/sites/all/modules/formexample/formexample.module on line 7.

the applicable code for the module is a follows:

/**
* Implementation of hook_menu().
*/
function formexample_menu($may_cache) {
$items = array();
if ($may_cache) {
$items[] = array(
'path' => 'sites/all/modules/formexample/formexample.module',
'title' => t('View the form'),
'callback' => 'formexample_page',
'access' => TRUE
);
}

return $items;
}

I have researched the form and believe it is either a coding problem or htaccess file issue for which I am at a loss. Any help would and direction would certainly be appreciated. Thanks

$may_cache is not in Drupal 6

kuldip - Gloscon - July 22, 2008 - 06:37

hi if you are using drupal 6 then $may_cache argument is not in _menu hook
please look at http://api.drupal.org/api/function/hook_menu/6

thanks

--
Kuldip Gohil
Software Engineer - Global Software Consulting (Gloscon)
1-888-DRUPAL-9 (378-7259)
http://www.gloscon.com

Hook Menu Modified -- Warning Cleared -- Page Still Not Found

AuctionTeamster - July 23, 2008 - 21:01

Thanks for helping clear up the warning and hook problem - I have ordered a couple of sources (books) which should help me with the Drupal 6 specific issues hopefully - as I am still finding the transition to Drupal difficult -- the site was up and running as a php/smarty template sight prior to the transition. If we can get past the nuances of drupal I think we will be fine -- having said that -- after the changes -- the page http://barlowauctions.com/?q=formexample still comes up as not found.

I am assuming it is a path issue -- how does drupal know where to find the page/module if no path is identified -- we are currently using hostican and suspect it has to do with where they have placed the drupal core. Any continued input is certainly appreciated

This is the code to our somewhat simplistic test form below:

<?php
// $Id$

/**
* Implementation of hook_menu().
*/
function hook_menu() {
$items = array();

$items['formexample'] = array (
'title' => t('View the form'),
'page callback' => 'formexample_page',
);

return $items;
}

/**
* Called when user goes to example.com/?q=formexample
*/
function formexample_page() {
$output = t('This page contains our example form.');

// Return the HTML generated from the $form data structure.
$output .= drupal_get_form('formexample_nameform');
return $output;
}

/**
* Defines a form.
*/
function formexample_nameform() {
$form = array();
$form['name'] = array(
'#title' => t('Your Name'),
'#type' => 'fieldset',
'#description' => t('What people call you.')
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Submit')
);
return $form;
}

/**
* Validate the form.
*/
function formexample_nameform_validate($form_id, $form_values) {
if ($form_values['user_name'] == 'King Kong') {
// We notify the form API that this field has failed validation.
form_set_error('user_name', t('King Kong is not allowed to use this form.'));
}
}

/**
* Handle post-validation form submission.
*/
function formexample_nameform_submit($form_id, $form_values) {
$name = $form_values['user_name'];
drupal_set_message(t('Thanks for filling out the form, %name', array('%name' => $name)));
}

Please try with the access callback and access agrguments

kuldip - Gloscon - July 24, 2008 - 04:05

# "access callback": A function returning a boolean value that determines whether the user has access rights to this menu item. Defaults to user_access() unless a value is inherited from a parent menu item..
# "access arguments": An array of arguments to pass to the access callback function. Integer values pass the corresponding URL component.

--
Kuldip Gohil
Software Engineer - Global Software Consulting (Gloscon)
1-888-DRUPAL-9 (378-7259)
http://www.gloscon.com

Menu Hook updated from Drupal 5 to 6

AuctionTeamster - August 2, 2008 - 21:39

Thanks all -- after some digging and hair pulling -- I made the following code changes to the menu hook and the form appeared.

/**
* Implementation of hook_menu().
*/
function formexample_menu() {
$items = array();

$items['formexample'] = array (
'title' => t('View the form'),
'page callback' => 'formexample_page',
'access arguments' => array('access content'),
'type' => TRUE
);

return $items;
}

 
 

Drupal is a registered trademark of Dries Buytaert.