1

Hi I am running the code on p247 of "Pro Drupal 7 Development", which includes the code below and then defines a form. I have enabled the module and cleared the cache but this isn't showing up in my menu system. What am I doing wrong?

/**
 * Implements hook_menu().
 */
function formexample_menu() {
  $items['formexample'] = array(
    'title' => 'View the sample form',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('formexample_nameform'),
    'access callback' => TRUE,
    'type' => MENU_NORMAL_ITEM
  );
  return $items;
}
4
  • have you cleared your cache
    – Nabil
    Feb 3, 2014 at 13:29
  • Welcome to Drupal Answers :) What do you mean by "this isn't showing up in my menu system"? What is your 'menu system' in this case? Do you get a 404 if you visit /formexample?
    – Clive
    Feb 3, 2014 at 13:30
  • Sorry, I thought that MENU_NORMAL_ITEM set two flags for an item to be visible in the menu tree and breadcrumbs. Sorry if I am mistaken. Visiting /formexample shows the name of the form but nothing else, so something else is clearly wrong.
    – Karin
    Feb 3, 2014 at 13:39
  • @Karin Try adding something like 'menu_name' => 'main-menu', where 'main-menu' is the machine name of the menu you're trying to add it to - that usually does the trick
    – Clive
    Feb 3, 2014 at 13:51

1 Answer 1

0

check http:localhost/formexample

Back-end admin panel menu :

$items['admin/structure/formexample'] = array(
    'title' => 'View the sample form',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('formexample_nameform'),
    'access callback' => TRUE,
    'type' => MENU_NORMAL_ITEM
  );

used this code

1
  • If the menu path is admin/structure/formexample, then visiting localhost/formexample doesn't show any form. Changing just the menu path doesn't make the code correct.
    – apaderno
    Feb 20, 2014 at 16:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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