Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Experimental project
This is a sandbox project, which contains experimental code for developer use only.
git clone --branch 7.x-1.x http://git.drupal.org/sandbox/mnico/2178611.git nodejs_debug
This module help to debug Drupal using Nodejs. How? Is like the dd() function of Devel but the variables will be printed in another page in real time. It is perfect when you work with a complex ajax in a form.
To print the variable this module use the Kint library, very nice to see objects or arrays.
You can use nd($variable);
Example
function mymodule_very_complex_form($form, &$form_state) {
$form['currency'] = array(
'#type' => 'select',
'#title' => t('Currency'),
'#options' => array(
'usd' => 'USD',
'eur' => 'EUR',
),
'#ajax' => array(
'callback' => 'mymodule_my_callback_ajax', // This return $form['next_step']
'wrapper' => 'my-wrapper',
),
);
$form['next_step'] = array(
'#type' => 'container',
'#prefix' => '<div id="my-wrapper">',
'#suffix' => '</div>',
);
if (isset($form_state['values']['currency'])) {
// If we want to see all $form_state tree after the ajax, the function
// print_r() will not help. We have another ways like dd() from devel
// module or nd() from this module and see in
// http://mydomain.com/nodejs-debug the variable with Kint format.
nd($form_state);
$form['next_step']['currency_selected'] = array(
'#markup' => t('You select !currency', array('!currency' => $form_state['values']['currency'])),
);
}
...
}
Dependencies
Developed by http://www.tifon.cl
Supporting organizations:
Project information
- Module categories: Developer Tools
- Created by mnico on , updated