arg(1) changed when doing AJAX I created a custom module named my_module.

In hook_menu() I define the following path.

$items['my-module/item'] = array(
  'title' =&gt; 'Item',
  'page callback' =&gt; 'drupal_get_form',
  'page arguments' =&gt; array('my_module_item_form'),
  'access arguments' =&gt; array('access item content'),
);


This is the code for my_module_item_form().

$arg = arg(1); // Problem here! Should return "item", right?
...
// $form[...] = array('#ajax' =&gt; ...);

$form['arg'] = array(
  '#type' =&gt; 'hidden',
  '#value' =&gt; $arg,
  // I also tried '#default_value'
)

// Submit field


Basically, I really need to obtain item in arg(1) and nothing else.

When I edit fields (not fields with ajax) and click submit, I can obtain the correct arg(1) in my hook_submit which is "item". Now, when I edit fields with ajax and click submit, arg(1) returns "ajax" which I do not like.

How should I obtain "item" in arg(1) in in the form submission handler during an ajax call in my form?
When implementing AJAX in a form, it will send a callback to system/ajax, if you didn't set your path in the AJAX properties. So, when you use arg(1) in your code, it will return ajax, which is the value assigned to the hidden form field.