Drupal AHAH form submission
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
On 2011-06-27, at 7:11 AM, Mukesh Agarwal wrote:
I dont see the value that I put in body field.. Am I doing it right?
I'd suggest looking at the ahah_example module in http://drupal.org/project/examples. It has a helper function that sets up the form variables properly that is invaluable in this sort of work. Also, instead of include_once, consider module_load_include(). --Andrew
Thanks Andrew! I discovered that you can only change form elements via ahah and not do an ajax submit.. checked out module_load_include, pretty cool.. On Mon, Jun 27, 2011 at 7:10 PM, Andrew Berry <andrewberry@sentex.net>wrote:
On 2011-06-27, at 7:11 AM, Mukesh Agarwal wrote:
I dont see the value that I put in body field.. Am I doing it right?
I'd suggest looking at the ahah_example module in http://drupal.org/project/examples. It has a helper function that sets up the form variables properly that is invaluable in this sort of work.
Also, instead of include_once, consider module_load_include().
--Andrew
-- Cheers, Mukesh Agarwal ________________________________ Innoraft Solutions <http://www.innoraft.com> || +91 8017220799
participants (2)
-
Andrew Berry -
Mukesh Agarwal