[development] Drupal AHAH form submission
Mukesh Agarwal
mukesh.agarwal17 at gmail.com
Mon Jun 27 11:11:36 UTC 2011
Hi Guys,
I'm using AHAH to submit a form - a node add/edit form - by adding a button
with ahah attributes. I registered a URL with my hook_menu for ahah
submission, then using $_POST I rebuild the form but I dont think I'm
getting the values of body form element in $_POST .. Following is my
code.. callback function of my ahah registered menu path..
include_once 'modules/node/node.pages.inc';
>
> $form_state = array('storage' => NULL, 'submitted' => FALSE);
>
> $form_build_id = $_POST['form_build_id'];
>
> // Get the form from the cache.
>
> $form = form_get_cache($form_build_id, $form_state);
>
> $args = $form['#parameters'];
>
> $form_id = array_shift($args);
>
> // We will run some of the submit handlers so we need to disable
> redirecting.
>
> $form['#redirect'] = FALSE;
>
> // We need to process the form, prepare for that by setting a few
> internals
>
> // variables.
>
> $form['#post'] = $_POST;
>
> $form['#programmed'] = FALSE;
>
> $form_state['post'] = $_POST;
>
> // This call recreates the form relying solely on the form_state that
> the
>
> // drupal_process_form set up.
>
> $form = drupal_rebuild_form($form_id, $form_state, $args,
> $form_build_id);
>
> watchdog('innoraft', 'Form Values: ' . serialize($form_state['values'
> ]));
>
>
>
> // Render the new output.
>
> unset($form['essay-box']['#prefix'], $form['essay-box']['#suffix']);
>
> $form['essay-box']['#value'] = 'Saved';
>
> $output = drupal_render($form['essay-box']);
>
> drupal_json(array('status' => TRUE, 'data' => $output));
>
> exit();
>
but when I do a watchdog of the form values or $_POST via:
watchdog('innoraft', 'Form Values: ' . serialize($form_state['values']));
I dont see the value that I put in body field.. Am I doing it right?
--
Cheers,
Mukesh Agarwal
________________________________
Innoraft Solutions <http://www.innoraft.com> || +91 8017220799
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/development/attachments/20110627/5396996f/attachment.html
More information about the development
mailing list