By nhck on
Dear fellow developers,
how do I go about fixing this error:
call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, 'node_form' was given in /htdocs/includes/form.inc in line 358.
What I do is:
* create a form using hook_form
* Use ahah to add x text-fields by having the user click on a button "add"
* Once I use the "preview" function the above error is displayed x-times
Thank you very much in advance for any help.
This is the function I use to render my ahah
function _lecture_ahah_appointments()
{
//get Post data
$form_state['post'] = $_POST;
$data = drupal_retrieve_form($_POST['form_id'],$form_state);
$form_build_id = $_POST['form_build_id']; //Cache ID
$form_state = array('submitted' => false);//reset form state
$cache = form_get_cache($form_build_id,$form_state); //get cached version
$i = count($cache['appointments']);
//add the new textfield, with the inserted data to form
$cache['appointments'][$i]['who-'.$i] = array(
"#type" => 'textfield',
'#weight' => 9,
'#value' => $data['#parameters'][1]['post']['who'],
);
//reset original form
$cache['appointments']['hinzu']['who']['#value'] = '';
//safe the form back to cache
form_set_cache($form_build_id,$cache,$form_state);
//Now alter the form
$cache['#post'] = $_POST;
$cache['#programmed'] = false;
$cache = form_builder($cache['form_id']['#value'] , $cache, $form_state);
//rebuild [appointments]-part, it will be replaced completly during in the form
$output = drupal_render($cache['appointments']);
print(drupal_to_js(array('data' => $output, 'status' => true) ) ); //bring everything back to drupal
exit();
}
Comments
I am stuck
Does anyone have an idea?
It is possible...
... That node.module isn't being included on that page.
Try sticking this code in the top of your function:
[Drupal++]
This doesn't help
This doesn't help unfortunately. The strange thing is, that the function is only missing upon "Previewing" the node. I also noticed that once all the other fields are filled out correct (e.g. title is not empty) and I press "Preview", all the ahah-content is gone.
Same problem
I have the same problem.This is what I do:
I have created a nodetype 'teilnahme' that includes a nodereference and a userreference.
When I try to
I get the same warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, 'node_form' was given in drupal/includes/form.inc on line 366.
The funny thing is: once logged in as admin and I clear cache via devel, the warning disappears and the form is built correctly. Unfortunately only until I hit reload. Then I get the warning again :-(
Including node.module didn't help, either.
Anybody else concerned?
maybe you should reset node
maybe you should reset node types cache?
see this http://api.drupal.org/api/function/node_get_types
<?php$new_blognode = new
works for me!
all the best
Lukas
--
www.netnode.ch
Yay!! works for me too,
Yay!! works for me too, thanks a lot!
works for me
good job - awesome!
how did you manage to get
how did you manage to get this work ?
I have blog content type.
I have PHP filter.
I pasted this code to the body and I am getting a blank page.
Could you give me some quick advice what am doing wrong ?
B.
add echo $output; to the end
add
echo $output;
to the end of the code.
druid.fi
It works
You can use shorter code to include nodes.pages.inc:
+1
+1
Contact me to contract me for D7 -> D10/11 migrations.
Excellent, this one works for
Excellent, this one works for me.
This works beautiful. +1000!
This works beautiful. +1000!
Just need to modify the submitter's uid
I have a very similar piece of code to the one provided by lukas.fischer (I landed on the post with the same problem as the original poster), the only difference is that I'm trying to modify the uid of the node on submission.
I have tried adding these lines to change the uid
I am running this code from a block, and it is properly rendering the form, but I can't seem to modify the uid of the node..?
Here is some background on what I'm doing with it...
You could try to change the
You could try to change the UID with form_alter on presave op.
Cheers
Lukas Fischer
--
www.netnode.ch - Swiss Drupal Heros
Hello, This code works
Hello,
This code works great:
But i'm using a Node Reference field. How to automaticly set the node reference field with the actual node where is the edit form?
Any idea?
Thanks :)