Code Snippets

Drupal 6 Multi Step Node Form Fix

Here is a fixed module of a Drupal 6 multi step node form. More information about this can be found here.

/* Implement hook_form_alter */
function YOUR_MODULE_NAME_form_alter(&$form, &$form_state, $form_id) {
   $form['#after_build'][] = '_customized_after_build_callback';
   $form['#validate'][] = '_customized_validate_callback';
}

/* remove conditional_fields validation callback */
function _customized_after_build_callback($form, $form_state) {
   if(in_array('conditional_fields_node_form_validate', $form['#validate'])) {
      array_splice($form['#validate'], in_array('conditional_fields_node_form_validate', $form['#validate']) - 1, 1);
   }
   return $form;
}

/* load conditional_fields validate function & js manually */
function _customized_validate_callback(($form, &$form_state) {
   if (module_exists('conditional_fields')) {
      conditional_fields_add_js($form['#conditional_fields']['settings']);
      $original_form_state = $form_state;
      conditional_fields_node_form_validate($form, $form_state);
      $form_state = $original_form_state;		
   }
}

 

Resource Tags: