0
module_load_include('inc', 'node', 'node.pages'); 

$form_id = 'reviewer_rating_node_form';

global $user;
$rating_id = views_get_view_result('get_rating', 'default', $nid, $user->uid);

// Rating hasn't been created yet. Create one.
if (empty($rating_id)) {
    // add node properties
    $newRating = new StdClass;
    $newRating->type = 'reviewer_rating';
    $newRating->title = $user->name . "'s rating of " . $nid;
    $newRating->uid = $user->uid;
    $newRating->created = strtotime("now");
    $newRating->changed = strtotime("now");
    $newRating->status = 1;
    $newRating->comment = 0;
    $newRating->promote = 0;
    $newRating->moderate = 0;
    $newRating->sticky = 0;

    // add CCK field data
    $newRating->field_rating_application[0]['nid'] = $nid;
    $newRating->field_rating_reviewer[0]['uid'] = $user->uid;

    // save node
    node_save($newRating);
}

$rating_node = node_load($rating_id[0]->nid);

$output = drupal_get_form('reviewer_rating_node_form', $rating_node);   
return $output;

This isn't working for me. If I dpm $rating_node it looks correct, but when I call drupal_get_form I get this error:

Fatal error: Cannot unset string offsets in includes\form.inc on line 498

If I log the $form variable at that line it's a string that starts with this:

Aform action="/devsite/node/423"  accept-charset="UTF-8" method="post" id="node-form" enctype="multipart/form-data">
<div> 

That "A" instead of a "<" might be a clue. I have no idea.

Any suggestions on what I'm doing wrong here?

1
  • Maybe you can explain which problem you're trying to solve... I get the feeling that there may be a simpler solution. Nov 3, 2011 at 20:37

2 Answers 2

1

Why don't you use Editview module? You can create an editview with a block display and show it on your page to edit your nodes from there.

0

My problem was that the function you call with drupal_get_form is supposed to return an array because drupal_get_form builds it for you, so calling drupal_get_form within drupal_get_form and returning it was not how it's meant to work. Instead I returned an object I built with drupal_retrieve_form.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.