I have created custom module called 'mymodule'.
In this URL localhost/es/mymodule/name/1/2/3, I have this field:
$form['name'] = array(
'#title' => t('Enter name'),
...
'#ajax' => array(
'event' => 'blur',
'callback' => 'mymodule_ajax_callback',
'wrapper' => 'my-wrapper',
'method' => 'replace',
),
...
);
My ajax callback is successfully called:
function mymodule_ajax_callback($form, &$form_state) {
...
return ...
}
However, inside 'mymodule_ajax_callback', I need to get the current URL arguments of the page such that arg(1) = 'name'
, arg(2) = 1
, arg(3) = 2
, and so on.
By nature, Drupal uses the URL system/ajax so calling arg(N)
does not work as I need it to be.
How to get the current URL arguments using arg()
inside the ajax callback?
EDIT 1:
I thought of using $_SESSION[...] = arg(1); $_SESSION[...] = arg(2); ...
on my form and calling the session variables on my ajax callback. But I am looking for a better way without using session but only using drupal methods if available.
$_GET
as well.