I created a form using Views and am implementing a module to use AHAH helper. It works great with a regular form such as 'user_register', but for some reason the error occurs on a form made using the Views module. The error message I get is:
warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, 'node_form' was given in /home8/jladevel/public_html/tysite/includes/form.inc on line 366.
Here is the module implementation:
function jeff_form_alter(&$form, &$form_state, $form_id)
{
if ($form_id =='job_node_form')
{
build_myForm(&$form, $form_state);
}
}
function build_myForm(&$form, $form_state)
{
// define our arrays
$main_service_department = array('none' => t("Select something"), 'a' => t("a"), 'b' => t("b"), 'c' => t("c"));
ahah_helper_register($form, $form_state);
$form['service_type'] = array(
'#type' => 'fieldset',
'#prefix' => '<div id="my-wrapper">', // This is our wrapper div.
'#suffix' => '</div>',
'#tree' => TRUE, // Don't forget to set #tree!
);
$form['service_type']['main_type'] = array(
'#type' => 'select',
'#title' => t('User Type'),
'#options' => $main_service_department,
'#default_value' => 'none',
'#ahah' => array(
'event' => 'change',
'path' => ahah_helper_path(array('service_type')),
'wrapper' => 'my-wrapper',
'effect' => 'fade',
),
);
}
I should also mention that if I use the AHAH property without the AHAH helper module, it works OK.
Comments
Comment #1
jefflane commentedSorry, I meant the form was created with CCK and is a content type. Nothing to do with Views.
Comment #2
zeropaperThe same happend to me, i just modified the module that way:
and (nearly) everything went fine...
@wim i posted this modification in #380312: Only AHAH javasript settings are send back (sorry, I didn't saw this issue earlier) ;)
Comment #3
jefflane commentedI attempted the changes you describe in this post as well as your original post, but I am still getting the error:
I believe the problem has something to do with 'node_form' being passed into the call_user_func_array within the following line of code (from ahah_helper.module):
Comment #4
zeropaperYou're right, indeed the problem has something to do with the 'node_form' function who can not be found because the required file (in this case 'node.pages.inc') isn't loaded.
If you look at line 366 of the 'form.inc' file, you'll find that the wanted function is the function called to generate the form (in this case node_form() ).
Personally, I had to put
ahah_helper_register($form, $form_state);in a hook_form_alter() because my script isn't the form generator (I'm currently working on a CCK field)...In your srcipt you may perhaps pass the $form_state as a reference (&$form_state) to fix that...
Comment #5
jefflane commentedThat's it! Moving the ahah_helper_register function to within the hook_form_alter worked for me.
Thanks for your help.