<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>Note that the linked issue is marked critical (so it will be fixed before D7 is released) and already has a patch. &nbsp;Rather than change your form, first try applying the patch and see if that fixes it for you.</div><div><br></div><div>- Ken Winters</div><br><div><div>On Mar 5, 2010, at 10:33 AM, Randy Fay wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">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">&lt;<a href="mailto:t.quathamer@gmx.net">t.quathamer@gmx.net</a>&gt;</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> &lt;<a href="http://drupalcode.org/viewvc/drupal/contributions/modules/weather/weather.forms.inc?view=markup&amp;pathrev=DRUPAL-7--1" target="_blank">http://drupalcode.org/viewvc/drupal/contributions/modules/weather/weather.forms.inc?view=markup&amp;pathrev=DRUPAL-7--1</a>&gt;<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, &amp;$form_state, $display_type, $display_number, $location_id=NULL) {<br> &nbsp;$mode = 'edit';<br> &nbsp;// Handle the addition of a new location.<br> &nbsp;if ($location_id == 'add') {<br> &nbsp; &nbsp;$mode = 'add';<br> &nbsp; &nbsp;$location_id = NULL;<br> &nbsp;}<br> &nbsp;// If the location exists, get the settings. If it does not exist,<br> &nbsp;// get the default location settings.<br> &nbsp;$settings = weather_get_location_settings($location_id);<br> &nbsp;$settings-&gt;places = weather_get_places($settings-&gt;country);<br> &nbsp;$form['country'] = array(<br> &nbsp; &nbsp;'#type' =&gt; 'select',<br> &nbsp; &nbsp;'#title' =&gt; t('Country'),<br> &nbsp; &nbsp;'#description' =&gt; t('Select a country to narrow down your search.'),<br> &nbsp; &nbsp;'#default_value' =&gt; $settings-&gt;country,<br> &nbsp; &nbsp;'#options' =&gt; drupal_map_assoc(weather_get_countries()),<br> &nbsp; &nbsp;'#ajax' =&gt; array(<br> &nbsp; &nbsp; &nbsp;'callback' =&gt; 'weather_location_settings_form_callback',<br> &nbsp; &nbsp; &nbsp;'wrapper' =&gt; 'weather_place_replace',<br> &nbsp; &nbsp;),<br> &nbsp;);<br> &nbsp;$form['place'] = array(<br> &nbsp; &nbsp;'#type' =&gt; 'select',<br> &nbsp; &nbsp;'#title' =&gt; t('Place'),<br> &nbsp; &nbsp;'#description' =&gt; t('Select a place in that country for the weather display.'),<br> &nbsp; &nbsp;'#default_value' =&gt; $settings-&gt;icao,<br> &nbsp; &nbsp;'#options' =&gt; $settings-&gt;places,<br> &nbsp; &nbsp;'#prefix' =&gt; '&lt;div id="weather_place_replace"&gt;',<br> &nbsp; &nbsp;'#suffix' =&gt; '&lt;/div&gt;',<br> &nbsp;);<br> &nbsp;$form['submit'] = array(<br> &nbsp; &nbsp;'#type' =&gt; 'submit',<br> &nbsp; &nbsp;'#value' =&gt; t('Save'),<br> &nbsp;);<br> &nbsp;// Do not show the 'delete' button if not in 'edit' mode.<br> &nbsp;if ($mode == 'edit') {<br> &nbsp; &nbsp;$form['delete'] = array(<br> &nbsp; &nbsp; &nbsp;'#type' =&gt; 'submit',<br> &nbsp; &nbsp; &nbsp;'#value' =&gt; t('Delete'),<br> &nbsp; &nbsp; &nbsp;'#submit' =&gt; array('weather_location_delete_submit'),<br> &nbsp; &nbsp;);<br> &nbsp;}<br> &nbsp;return $form;<br> }<br> <br> function weather_location_settings_form_callback($form, $form_state) {<br> &nbsp;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 &nbsp;970.462.7450<br><br></blockquote></div><br></body></html>