Nodejs Debug

Categories

Component ID

2178611

Component name

Nodejs Debug

Component type

module

Maintenance status

Development status

Component security advisory coverage

not-covered

Component created

Component changed

Component body

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