Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7053761
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:32:40+00:00 2026-05-28T03:32:40+00:00

I have a hook menu $items[‘node/%/delete’] = array( ‘title’ => ‘Delete’, ‘load arguments’ =>

  • 0

I have a hook menu

$items['node/%/delete'] = array(
        'title' => 'Delete',
        'load arguments' => array(3),
        'description' => 'Confirm the action.',
        'page callback' => 'drupal_get_form',
        'page arguments' => array('_mymodule_delete', 1),
        'type' => MENU_CALLBACK,
        'weight' => -4,
    );
return $items;

What do I need to do to make sure the following function gets to work (and the variables get their values):

function _mymodule_delete ($form, $form_state, $node) {
...
}

In orther words, how do I get values in the three arguments given ($form, $form_state and $node)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T03:32:40+00:00Added an answer on May 28, 2026 at 3:32 am

    EDIT

    I’ll have another go…

    The only argument(s) you need to pass to drupal_get_form, other than the name of the form itself, are arguments specific to that form function; $form and $form_state are automatically added for you. So if you want to call a form with a signature of _mymodule_delete($form, $form_state, $node) you would use this code:

    $form = drupal_get_form('_mymodule_delete', $the_node);
    

    When you apply this to the menu router, all you’re looking to do is pass the loaded $node through as an argument to drupal_get_form in the same way. Your router item would look like this:

    $items['node/%node/delete'] = array(
      'title' => 'Title',
      'page callback' => 'drupal_get_form',
      'page arguments' => array('_mymodule_delete', 1),
      'access arguments' => array('access content'),
      'type' => MENU_CALLBACK,
      'weight' => -4,
    );    
    

    Your original example is missing the access arguments/access callback attribute which would make your page inaccessible (403 status) so I’ve added in the ‘standard’ access arguments of access content. You’ll probably want to change this for your own needs.

    The string node/%node/delete (the router path) and the page arguments array are the bits you’re probably interested in here. When you want to pass an argument from the URL to a callback function you simply include it’s ‘index’ as one of the page arguments. This index comes from a zero-based array of the router path when split by the separator (/).

    In this example the three parts of the path are:

    0 => 'node',
    1 => '%node',
    2 => 'delete'
    

    As the variable element of the path is in index position 1, that’s the number we pass to the page arguments array.

    Just to make it a little more complicated, the variable passed in through the path can also be passed to a load function before it’s passed to the page callback function. For some reason the naming convention in Drupal is that a function with the name of the variable with _load appended to it will be the name of the function called.

    So in this case, node_load is called. If your router path was, for example, books/%book then a function called book_load would be called to prepare the variable to be passed to the page callback function.

    The load function is optional, if your path was node/%/delete then the argument passed to your form callback would be the exact string (in this case a node ID) from the URL.

    I’m sure you’ve seen it but the hook_menu() documentation tries its best to explain all this, I can understand why it would be difficult to comprehend though.

    Hope that helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's the issue: I have a hook in IE that reacts on WebBrowser.OnNavigateComplete2 event
I want to have a Mercurial hook that will run before committing a transaction
I have a post-commit hook in svn that runs fine from the command line
I have an app which uses a keyboard hook procedure in a library. The
I have a Delphi application similar to Taskbar Shuffle that includes a hook dll.
How can I hook up an event to a function name I have defined
Let's say we have a continuous integration server. When I check in, the post-hook
I have not been able to get drupal_get_form to pass on the node data.
We have a hook in Mercurial that posts the changeset message and a link
I'm trying to create a node form for a custom type. I have organic

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.