Search code examples
formsdrupalmoduledrupal-6ahah

Drupal Ahah helper form error: warning: call_user_func_array() expects parameter 1 to be a valid callback


I have forms with Ahah helper. When I tried to fill the form, it always getting this error:

warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'A' not found or invalid function name in xxx\includes\form.inc on line 378.

A = name of function, but that function is exist xxx = location of drupal

Line 378 is:

$form = call_user_func_array(isset($callback) ? $callback : $form_id, $args);

At page_new_init, there is no error at all. But, at page_initedit there's always error. This is the .module code:

$items['new/init/1'] = array(
    'title' => 'Add new',
    'type' => MENU_LOCAL_TASK, //MENU_NORMAL_ITEM,
    'page callback' =>'page_new_init',
'access arguments' => array('new'),
);  

$items['new/editinit'] = array(
    'title' => 'Edit',
    'type' => MENU_CALLBACK, //MENU_NORMAL_ITEM,
    'page callback' =>'page_initedit',
'access arguments' => array('new'),
'file' => 'act.edit.inc',
); 

And this is the form on function "page_new_init":

function page_new_init(){
  global $user;

 $output .= drupal_get_form('form_new_add2',$id,$codeact);

  return $output;
}

function form_new_add2(){
  global $user;

    $form = array();
    ahah_helper_register($form, $form_state);
    drupal_add_js("sites/all/modules/act/javascript/jss.js");

    $form['input']['account'] = array(
    '#type' => 'textfield',
    '#title' => t('Account Code'),
    '#size' => 60,
    '#default_value' => $account,
    '#required' => TRUE,
    '#autocomplete_path' =>'compose/code',
    '#ahah' => array(
        'event'   => 'change',
        'path'    => ahah_helper_path(array('input')),
        'wrapper' => 'input-wrapper',
        'method' => 'replace',
        'progress' => 'throbber',
    ),

    $form['input']['access_code'] = array(
    '#type' => 'select', 
    '#title' => t('Access Code'),
    //'#required' => TRUE,
    '#default_value' => $access_code,
    '#options' => opt_accesscode(),
    );


  return $output;
}

And this is the other function "page_initedit":

function page_initedit(){
  global $user;

 $output .= drupal_get_form('form_initedit',$id,$codeact);

  return $output;
}

function form_initedit(){
  global $user;

    $form = array();
    ahah_helper_register($form, $form_state);
    drupal_add_js("sites/all/modules/act/javascript/jss.js");

    $form['input']['account'] = array(
    '#type' => 'textfield',
    '#title' => t('Account Code'),
    '#size' => 60,
    '#default_value' => $account,
    '#required' => TRUE,
    '#autocomplete_path' =>'compose/code',
    '#ahah' => array(
        'event'   => 'change',
        'path'    => ahah_helper_path(array('input')),
        'wrapper' => 'input-wrapper',
        'method' => 'replace',
        'progress' => 'throbber',
    ),

    $form['input']['access_code'] = array(
    '#type' => 'select', 
    '#title' => t('Access Code'),
    //'#required' => TRUE,
    '#default_value' => $access_code,
    '#options' => opt_accesscode(),
    );


  return $output;
}

On "page_new_init", there is no error at all, Ahah helper works fine. But on "page_initedit" the error comes up:

warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'form_initedit' not found or invalid function name in drupal\includes\form.inc on line 378.

What should I do?


Solution

  • In .module file, I have to load .inc file. That's what I forgot! :(

    include_once(drupal_get_path('module', 'act') .'/act.edit.inc');