3

I am trying to use the Date module in a module I am writing, but I get the following errors:

Warning: Missing argument 1 for myform_data_entry_form() in myform_data_entry_form() (line 28 of D:\wamp\www\drupal\sites\all\modules\myform\myform.module).
Warning: Missing argument 2 for myform_data_entry_form() in myform_data_entry_form() (line 28 of D:\wamp\www\drupal\sites\all\modules\myform\myform.module).

This is the code I am using in my module.

function myform_help($path, $arg) {
switch ($path) {
      case "admin/help#myform":
        return '<p>'.  t("Displays links to nodes created on this date") .'</p>';
        break;
    } 
 }

function myform_menu() {
  $items['myform/data_entry_form'] = array(
    'type' => MENU_CALLBACK,
    'access arguments' => array('access content'),
    'page callback' => 'myform_data_entry_form' 
  );
  return $items;
}


function myform_permission(){
  return array(
    'access myform content' => array(
      'title' => t('Access content for the myform module')
    ) 
  );
}

function myform_data_entry_form($form,&$form_submit) {
  $form['curdate'] = array('#type' => 'date_popup', '#title' => 'Date', '#date_format' => 'd/m/Y');

  return $form;
}
0

1 Answer 1

5

Drupal forms should be called using the drupal_get_form() method, even from menu callbacks. Your menu item needs to look like this:

$items['myform/data_entry_form'] = array(
  'type' => MENU_CALLBACK,
  'access arguments' => array('access content'),
  'page callback' => 'drupal_get_form',
  'page arguments' => array('myform_data_entry_form') 
);

return $items;

Make sure you clear Drupal's caches each time you make a change in hook_menu(), otherwise it won't get picked up.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.