Hi,

When I check the option "Display below post or comments"
I got following error with a cck content type node showing.

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

Thanks for going into this!

greetings,
Martijn

CommentFileSizeAuthor
#6 nodecomment_validation_234501.patch1.62 KBsirkitree

Comments

summit’s picture

Hi,

Going into this, this is not related to the cck content type. It is the situation when the contenttype is set not to have comments. Then it is set to -none-.

I believe this function gives then the error, thanks to the help of marc from openresort:

function nodecomment_form($node) {
  global $user;
  
  $comment_type = variable_get('comment_type_'. $node->type, variable_get('default_comment_type', ''));
  $new_node = array(
    'uid' => $user->uid,
    'name' => $user->name,
    'type' => $comment_type,
    'comment_target_nid' => $node->nid,
  );
  return drupal_get_form($comment_type . '_node_form', $new_node);
}

There needs to be placed a certain 'IF" somewhere that when the contenttype is set NOT to have comments, that then this function is not triggered. The $comment_type is then empty!
I don't know the code enough to set it correct.

Please place the IF where it is the most efficient way in the code.
Thanks for going into this!

Greetings,
Martijn

sirkitree’s picture

Status: Active » Fixed

I changed the above function to the following:

function nodecomment_form($node) {
  $comment_type = variable_get('comment_type_'. $node->type, variable_get('default_comment_type', ''));
  if ($comment_type) {
    global $user;
    $new_node = array(
      'uid' => $user->uid,
      'name' => $user->name,
      'type' => $comment_type,
      'comment_target_nid' => $node->nid,
    );
    return drupal_get_form($comment_type .'_node_form', $new_node);  
  }
}

This takes care of the problem. Committing.

summit’s picture

Great, thanks!
Greetings, Martijn

sirkitree’s picture

Even though I committed this to code, it is probably not the ideal way to deal with this. We should probably validate the node-edit form to make sure that if comments are enabled ($form['comment'] == 1 || 2) then make sure that a comment type ($form['comment_type']) and a view ($form['comment_view']) are chosen as well.

I'm having trouble trying to validate on the element level, so I probably need to validate on the form level. I'll give it a try and let you know how it goes.

sirkitree’s picture

Assigned: Unassigned » sirkitree
Status: Fixed » Active
sirkitree’s picture

Status: Active » Needs review
StatusFileSize
new1.62 KB

so that was pretty easy. try this patch out.

summit’s picture

Hi, I gave seen you already committed it to .dev, thanks. It looks ok to me! greetings, Martijn.

sirkitree’s picture

Status: Needs review » Fixed
Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.