I am trying to edit/save nodes on a certain spot on my page using jQuery + Ajax.
I was able to kind of get it working using drupal_json() and drupal_get_form().

The function drupal_get_form("mynodetype_form") is able to get the form and all my fields. This works great.

But, when I tried to do:

$node = node_load($nid);
drupal_get_form("mynodetype_form", $node);

This didn't give me the form for the existing node for editing, like I wanted. Instead, it just gave me the blank form again.

Is there another (better) way to be doing this? This question isn't really related to ajax/jquery but I threw that in since it might help to know what I am ultimately trying to do.

How can I get the editing version of a form (with prepopulated values)?

Comments

JohnForsythe’s picture

You might want to check out AJAX Table, it comes with some demos that deal with AJAX node editing.

--
John Forsythe
Need reliable Drupal hosting?

meric’s picture

I don't know if this is what you want, but you can do:

<?php
//let's load an edit page
$node = node_load($nid);
$output = node_page_edit($node); //store the html in a variable, like $output.

//we can try to print it
print $output;
?>

node_page_edit returns the HTML markup of the [form] element of the edit page for the specified node..

Hope this helps.

sukh.singh’s picture

Can you tell me thorie79 how to edit/save node with jquery? As i also need to make like this.

druvision’s picture

try the activedit module in the jstools project.

Amnon
-
Professional: Levavie Integrated Consultingl | Drupal Development & Consulting
Personal: Hitech Dolphin: Regain Simple Joy :)

Anybody’s picture

Here you can find a solution by TimToronto that worked great for me:
https://www.drupal.org/node/1933314#comment-9667597

http://www.DROWL.de || Professionelle Drupal Lösungen aus Ostwestfalen-Lippe (OWL)
http://www.webks.de || webks: websolutions kept simple - Webbasierte Lösungen die einfach überzeugen!
http://www.drupal-theming.com || Individuelle Responsive Themes