lunedì 8 dicembre 2014

Aggiungere javascript a una form drupal

Creare un modulo personalizzato dove aggiungere:

function nome modulo_form_alter(&$form, &$form_state, $form_id) {

  switch ($form_id) {
    case 'id_form':
    dsm($form_id);
      $form['#after_build'][] = 'nomemodulo_after_build';
      break;
  }
}

function nomemodulo_after_build($form, &$form_state) {
  $path = drupal_get_path('module', 'nomemodulo');
  drupal_add_js ("$path/custom_javascript.js");
  return $form;
}

Nessun commento: