Node.save with flex

Events happening in the community are now at Drupal community events on www.drupal.org.
reecex's picture

Hey guys im being driven up the wall all of my services calls are working in flex except node.save everytime i try to use it i get a

"call_user_func_array(): First argument is expected to be a valid callback, 'node_form' was given"

heres the flex fault code>.
.faultCode:AMFPHP_RUNTIME_ERROR faultString:'call_user_func_array(): First argument is expected to be a valid callback, 'node_form' was given' faultDetail:'I:\My Documents\webroot........\includes\form.inc on line 358'

the error occurs even after following the recipes screen cast

if its helps im using drupal 6.2, amfphp 1.9beta and have tried both (services module 6.x-0.9 and 6.x-1.x with no success)

every other call works fine within flex for the services module. if anyone could at least point me in the right direction for finding a solution it would be much appreciated

Comments

found the problem function

reecex's picture

found the problem function for me im sure its because im doing something wrong but for the time being it works and allows me to continue concentrating on the project at hand...

the problem function for me was the node_save_services function inside the node_service.module in release 6.x-0.9 release >>

$Id: node_service.module,v 1.5.2.3

function node_service_save($edit) {
  if ($edit['nid']) {
    $node = node_load($edit['nid']);
    if ($node->nid) {
      $ret = drupal_execute($node->type .'_node_form', $edit, $edit);
    }
  }
  else {
    $ret= drupal_execute($edit['type'] .'_node_form', $edit, $edit);
  }
  if ($errors = form_get_errors()) {
    return services_error(implode("\n", $errors));
  }
  watchdog('content', t('@type: updated %title.', array('@type' => t($node->type), '%title' => $node->title)), WATCHDOG_NOTICE, l(t('view'), 'node/'. $node->nid));
  return $ret;
}

i replaced it with an older version from the services 6.x-1.x-dev function

$Id: node_service.module,v 1.5.2.2

function node_service_save($edit) {
 
  // validate node 
  node_validate($edit);
  if ($errors = form_get_errors()) {
    return services_error(implode("\n", $errors));
  }

  $node = node_submit($edit);
  node_save($node);
  watchdog('content', t('@type: updated %title.', array('@type' => t($node->type), '%title' => $node->title)), WATCHDOG_NOTICE, l(t('view'), 'node/'. $node->nid));
  return $node;
}

if its something im not including as to why this is erroring out on me with the newer version please let me now but for now it works and my philosophy is if it ain't broke don't fix it

same problem

attiks's picture

FYI I have the same problem, and the same solution is working :p

possible solution

civicpixel's picture

I ran into this as well tonight going through the screen cast at http://files.thisbythem.com/screencasts/services-2.mov. Was having too much fun to stop, so I made a quick effort at updating the drupal_execute code referenced above. I think some others may have already been working on the problem as well, but I posted my patch to http://drupal.org/node/139131...

Services

Group organizers

Group categories

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: