function weather_js in Weather 6.5
Return a new place selection box based on the country selection
1 string reference to 'weather_js'
- weather_menu in ./
weather.module - Implementation of hook_menu().
File
- ./
weather.module, line 741 - Display <acronym title="METeorological Aerodrome Report">METAR</acronym> weather data from anywhere in the world
Code
function weather_js() {
// Get the current selected country for the new places
$form_state = array(
'values' => $_POST,
);
$new_places = weather_get_places($form_state['values']['country']);
// Get form from cache and store modified place selection
$form = form_get_cache($_POST['form_build_id'], $form_state);
$form['place'] = array(
'#type' => 'select',
'#title' => t('Place'),
'#description' => t('Select a place in that country for the weather display.'),
'#options' => $new_places,
);
form_set_cache($_POST['form_build_id'], $form, $form_state);
$form += array(
'#post' => $_POST,
'#programmed' => FALSE,
);
// Rebuild the form.
$form_state = array(
'submitted' => FALSE,
);
$form = form_builder('weather_custom_block_form', $form, $form_state);
// Render the new output.
$output = theme('status_messages') . drupal_render($form['place']);
// Don't call drupal_json(). ahah.js uses an iframe and
// the header output by drupal_json() causes problems in some browsers.
print drupal_to_js(array(
'status' => TRUE,
'data' => $output,
));
exit;
}