Active
Project:
AHAH helper
Version:
6.x-2.0
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
17 Aug 2010 at 16:42 UTC
Updated:
19 Aug 2010 at 17:34 UTC
An error 500 occures when you want to rebuild the whole form.
The error message returned by javascript is:
An HTTP error 500 occured.
/ahah_helper/%3Cform%3E
The code to generate this error is:
<?php
/**
* Form builder; multistep form.
*
* The form is built differently depending on which step we're on.
*
* @param $form_state Standard Drupal form_state array.
*/
function ahah_multistep(&$form_state) {
$form = array('#tree' => TRUE);
ahah_helper_register($form, $form_state);
// Display page 2 if $form_state['storage']['page_two'] is set
if (isset($form_state['storage']['page_two'])) {
return ahah_multistep_page_two($form);
}
// $categories = ...
// $options = ...
// Build stuff
foreach ($categories as $key => $title) {
$form['vote'][$key] = array(
'#type' => 'slider',
'#title' => $title,
'#name' => $key, // TODO: define it with the $key variable.
'#options' => $options,
);
}
$form['next'] = array(
'#type' => 'submit',
'#ahah' => array(
'event' => 'click',
'path' => ahah_helper_path(),
'wrapper' => 'ahah_multistep', // form id.
'effect' => 'fade',
),
'#value' => t('Next'),
);
return $form;
}
?>
When I am manually setting a path for the #ahah property the form get validated and I get the second step as it was supposed to work.
The next button becomes:
<?php
$form['next'] = array(
'#type' => 'submit',
'#ahah' => array(
'event' => 'click',
'path' => 'ahah_multistep_js',
'wrapper' => 'ahah_multistep',
'effect' => 'fade',
),
'#value' => t('Next'),
);
?>In the ahah_multistep.module I add then:
<?php
/**
* Implementation of hook_menu().
*/
function ahah_multistep_menu() {
$items = array();
// AJAX AHAH Multistep form.
$items['ahah_multistep_js'] = array(
'page callback' => 'ahah_helper_render',
'access callback' => 'user_is_logged_in',
'type' => MENU_CALLBACK,
);
return $items;
}
?>Then it works, but I have to write this callback.
Comments
Comment #1
ceejayoz commentedChange
ahah_helper_path()toahah_helper_path(array())and it should work, if I'm remembering what I had to do.