Hi all. I need to import some blog's node from another site. I have tried this:
$form_id = 'blog_node_form'; $form['values'] = array( 'title' => 'pippo', 'taxonomy[tags][3]' => 'prova', 'body' => 'Io sono il corpo del messaggio', 'format' => 1, 'field_old_id[0][value]' => '11', 'name' => 'wheel' );
$k = drupal_execute($form_id,$form);
Field_old_id is a cck's field.
When I try to run this code Drupal return me this error: warning: call_user_func_array() [function.call-user-func-array http://distrofici/admin/zblabs/function.call-user-func-array]: First argument is expected to be a valid callback, 'node_form' was given in /home/michel/LAVORI_ZB/www/distrofici/includes/form.inc on line 366.
Where is my error ?
Tnx.
Hi. You have to pass another variable to drupal_execute, with node information. If I remember well it should be like this:
$form_id = 'blog_node_form'; $form['values'] = array( 'title' => 'pippo', 'taxonomy[tags][3]' => 'prova', 'body' => 'Io sono il corpo del messaggio', 'format' => 1, 'field_old_id[0][value]' => '11', 'name' => 'wheel',
'type' =>"your-type" // eg. story
);
$k = drupal_execute($form_id,$form, $form);
Hope it works.
Saluti, Luca
Davide Michel 'ZioBudda' Morelli ha scritto:
Hi all. I need to import some blog's node from another site. I have tried this:
$form_id = 'blog_node_form'; $form['values'] = array( 'title' => 'pippo', 'taxonomy[tags][3]' => 'prova', 'body' => 'Io sono il corpo del messaggio', 'format' => 1, 'field_old_id[0][value]' => '11', 'name' => 'wheel' );
$k = drupal_execute($form_id,$form);Field_old_id is a cck's field.
When I try to run this code Drupal return me this error: warning: call_user_func_array() [function.call-user-func-array http://distrofici/admin/zblabs/function.call-user-func-array]: First argument is expected to be a valid callback, 'node_form' was given in /home/michel/LAVORI_ZB/www/distrofici/includes/form.inc on line 366.
Where is my error ?
Tnx.
-- Michel 'ZioBudda' Morelli michel@ziobudda.net Consulenza sistemistica in ambito OpenSource. Sviluppo applicazioni web dinamiche (LAMP+Ajax) Telefono: 0200619074 Telefono Cell: +39-3939890025 -- Fax: +39-0291390660
http://www.ziobudda.net ICQ: 58351764 http://www.ziobuddalabs.it Skype: zio_budda http://www.ziodrupal.net MSN: michel@ziobuddalabs.it JABBER: michel@ziobuddalabs.it
Hi. You have to pass another variable to drupal_execute, with node information. If I remember well it should be like this:
[snip]
$k = drupal_execute($form_id,$form, $form);
Hmm, I'm not so sure. drupal_execute expects exactly two parameters, not three. (API definition for Drupal 5: http://api.drupal.org/api/function/drupal_execute/5 API definition for Drupal 6: http://api.drupal.org/api/function/drupal_execute/5)
One thing that I can see wrong in the code that that the original poster quoted is that he is submitting an array of arrays, when only an array is called for.
$form['value'] = array( // stuff );
should actually probably be
$form_values = array( // stuff );
Best, William
There is an interesting discussion about drupal_execute here: http://drupal.org/node/131704 || I followed this to get node submitted properly.
bye luca
William Smith ha scritto:
Hi. You have to pass another variable to drupal_execute, with node information. If I remember well it should be like this:[snip]
$k = drupal_execute($form_id,$form, $form);Hmm, I'm not so sure. drupal_execute expects exactly two parameters, not three. (API definition for Drupal 5: http://api.drupal.org/api/function/drupal_execute/5 API definition for Drupal 6: http://api.drupal.org/api/function/drupal_execute/5)
One thing that I can see wrong in the code that that the original poster quoted is that he is submitting an array of arrays, when only an array is called for.
$form['value'] = array( // stuff );
should actually probably be
$form_values = array( // stuff );
Best, William