I want to include an 'editview' on a node page and I define this in my node.tpl.php file, like this:

 $viewName = 'Articles';
 $viewDisplay = 'page_1';
 print views_embed_view($viewName, $viewDisplay);

Other views work fine but when I call an 'editview' view I get the error:

warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, 'editview_node_form_3' was given in ...includes/form.inc on line 371

'Editview' works fine if accessed on it's own using a defined URL for the view, but not, as you can see, when called programatically. Any ideas why?

Comments

jelenex’s picture

Same error happens to me when I try to include 'Editview' block on the node edit form (like it's described in intro of this module). However, the 'Editview' block works when it's enabled on the normal node view page.

BWPanda’s picture

Title: Error when programatically including editview view » call_user_func_array warning
Version: 6.x-1.0-beta1 » 6.x-1.x-dev
Priority: Normal » Critical

I have also be experiencing this issue when trying to add an Editview block to a node.

It's got something to do with the editview_forms() function (specifically when it's called from drupal_render_form() in Drupal's form.inc file), but I'm not sure exactly what...
It runs fine (even displaying the Editview block form) without any warnings if you clear the cache, but as soon as you refresh normally, it goes back to displaying warnings and not working properly.

Marking as critical and marking the following issues as duplicates of this one:
#554756: Not working in a block on a node/x/edit form
#649050: What about the Argument Code in D6/Views 2

BWPanda’s picture

Anyone been able to look into this?

radiobuzzer’s picture

Status: Active » Needs review

Found it !

It's line 45 of file theme/editview.theme.inc

instead of

    $variables['form'] = drupal_get_form('editview_node_form_'. $variables['row']->nid, $node, $variables['view'], $variables['id'], request_uri());

should be

    $variables['form'] = drupal_get_form('editview_node_form' , $node, $variables['view'], $variables['id'], request_uri());

It's the theming part of the module. At this line, the name of the function (callback) that is producing the form is passed to drupal form API, so that drupal "knows" which form to load. For some reason, the form ID was concatenated to the callback name following an underscore, resulting to an invalid callback.
ode_form callback , resulting into an invalid callback

These changes have stopped the errors displaying when being a block in edit page of a node (as described in module page), and the form loads fine. I haven't tested whether this change breaks the form displaying in other pages.

Please somebody test it and commit it as a patch.

radiobuzzer’s picture

Status: Needs review » Patch (to be ported)
roderik’s picture

Status: Patch (to be ported) » Needs review

It's the theming part of the module. At this line, the name of the function (callback) that is producing the form is passed to drupal form API, so that drupal "knows" which form to load. For some reason, the form ID was concatenated to the callback name following an underscore, resulting to an invalid callback.

FYI: in principle it's perfectly alright to concatenate a number to the form ID. That's what hook_forms() is for.

So what you describe here is not the exact cause of the problem.
(Maybe editview_node_form() should be moved into editview.module, or editview.views.inc should be module_load_include()'d, to solve the problem? )