Hi Tobias - <br><br>The problem is the drupal_goto() in your submit function. The submit function is being processed during the AJAX callback... and the drupal_goto() takes control away from the callback.<br><br>If I'm not mistaken, this behavior will change when <a href="http://drupal.org/node/684846">http://drupal.org/node/684846</a> lands, but for now, you'll need to not do a drupal_goto() in your submit function.<br>
<br>-Randy<br><br><div class="gmail_quote">On Fri, Mar 5, 2010 at 4:19 AM, Tobias Quathamer <span dir="ltr"><<a href="mailto:t.quathamer@gmx.net">t.quathamer@gmx.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi all,<br>
<br>
I've run into a problem with D7 and AJAX-enabled forms. What I try to do<br>
is to have a selection list use options depending on another selection<br>
list. I've looked at the code of the AJAX examples module, but I could<br>
not find why my code is not working. A part of my code follows, the<br>
complete code can be found here (lines 356 onwards):<br>
<<a href="http://drupalcode.org/viewvc/drupal/contributions/modules/weather/weather.forms.inc?view=markup&pathrev=DRUPAL-7--1" target="_blank">http://drupalcode.org/viewvc/drupal/contributions/modules/weather/weather.forms.inc?view=markup&pathrev=DRUPAL-7--1</a>><br>
<br>
I've separated those function calls into their own file, they are not in<br>
the main .module file. Could this be a cause of problems? I would<br>
appreciate any hints or pointers.<br>
<br>
Regards,<br>
Tobias<br>
<br>
<br>
<br>
<br>
function weather_location_settings_form($form, &$form_state, $display_type, $display_number, $location_id=NULL) {<br>
$mode = 'edit';<br>
// Handle the addition of a new location.<br>
if ($location_id == 'add') {<br>
$mode = 'add';<br>
$location_id = NULL;<br>
}<br>
// If the location exists, get the settings. If it does not exist,<br>
// get the default location settings.<br>
$settings = weather_get_location_settings($location_id);<br>
$settings->places = weather_get_places($settings->country);<br>
$form['country'] = array(<br>
'#type' => 'select',<br>
'#title' => t('Country'),<br>
'#description' => t('Select a country to narrow down your search.'),<br>
'#default_value' => $settings->country,<br>
'#options' => drupal_map_assoc(weather_get_countries()),<br>
'#ajax' => array(<br>
'callback' => 'weather_location_settings_form_callback',<br>
'wrapper' => 'weather_place_replace',<br>
),<br>
);<br>
$form['place'] = array(<br>
'#type' => 'select',<br>
'#title' => t('Place'),<br>
'#description' => t('Select a place in that country for the weather display.'),<br>
'#default_value' => $settings->icao,<br>
'#options' => $settings->places,<br>
'#prefix' => '<div id="weather_place_replace">',<br>
'#suffix' => '</div>',<br>
);<br>
$form['submit'] = array(<br>
'#type' => 'submit',<br>
'#value' => t('Save'),<br>
);<br>
// Do not show the 'delete' button if not in 'edit' mode.<br>
if ($mode == 'edit') {<br>
$form['delete'] = array(<br>
'#type' => 'submit',<br>
'#value' => t('Delete'),<br>
'#submit' => array('weather_location_delete_submit'),<br>
);<br>
}<br>
return $form;<br>
}<br>
<br>
function weather_location_settings_form_callback($form, $form_state) {<br>
return $form['place'];<br>
}<br>
<font color="#888888"><br>
<br>
--<br>
Tobias Quathamer | Quidquid latine dictum sit, altum viditur.<br>
Hamburg, Germany | (Whatever is said in Latin sounds profound.)<br>
<br>
</font></blockquote></div><br><br clear="all"><br>-- <br>Randy Fay<br>Drupal Development, troubleshooting, and debugging<br><a href="mailto:randy@randyfay.com">randy@randyfay.com</a><br>+1 970.462.7450<br><br>