You are here

function weather_es_edit_form in Weather_es 7

Same name and namespace in other branches
  1. 6.3 weather_es.module \weather_es_edit_form()

@author jmsirvent

Parameters

$form_state, $wid: 0: site, int: user->uid:

1 string reference to 'weather_es_edit_form'
weather_es_menu in ./weather_es.module
hook_menu

File

./weather_es.module, line 176

Code

function weather_es_edit_form($form, &$form_state, $wid) {

  // From: http://jbenner.net/blog/prevent-ahah-the-right-way-from-breaking-with-validation
  $form['#cache'] = TRUE;

  // Make sure the form is cached.
  // Pull the correct action out of form_state if it's there to avoid AHAH+Validation action-rewrite.
  if (isset($form_state['action'])) {
    $form['#action'] = $form_state['action'];
  }
  $form['combo'] = array(
    '#type' => 'fieldset',
    '#title' => t('Select a province and a city'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
    '#tree' => TRUE,
  );
  $form['combo']['provincia'] = array(
    '#title' => t('Province'),
    '#description' => t('Province of the city'),
    '#type' => 'select',
    '#options' => _weather_es_provinces(),
    '#default_value' => '---',
    //'#ahah' => array(
    '#ajax' => array(
      'callback' => 'weather_es_update_cities_callback',
      'wrapper' => 'city-dropdown',
      'method' => 'replace',
      'effect' => 'none',
    ),
  );
  $province = isset($form_state['values']) ? $form_state['values']['combo']['provincia'] : '---';
  $form['combo']['ciudad'] = array(
    '#title' => t('City'),
    '#type' => 'select',
    '#description' => t('City to show the forecast'),
    '#options' => _weather_es_cities($province),
    '#prefix' => '<div id="city-dropdown">',
    '#suffix' => '</div>',
  );

  /* This doesn't work this way anymore...
    $form['idioma'] = array(
      '#type' => 'radios',
      '#title' => t('Languages'),
      '#options' => array(
        'es' => t('Spanish'),
        'ca' => t('Catalan'),
        'eu' => t('Euskera'),
        'gl' => t('Galician'),
        'en' => t('English'),
        'fr' => t('French'),
      ),
      '#description' => t('Choose the language you will see the weather data.'),
      '#default_value' => 'es',
    );
     *
     */
  $form['informacion'] = array(
    '#type' => 'checkboxes',
    '#title' => t('What information do you want to see?'),
    '#options' => array(
      'rain' => t('Rain probability'),
      'snow' => t('Snow level'),
      'sky' => t('Sky state'),
      'wind' => t('Wind direction and speed'),
      'gust' => t('Gust of wind'),
      'temperature' => t('Temperature'),
      'chill' => t('Chill'),
      'humidity' => t('Humidity'),
      'uv' => t('UV'),
    ),
    '#default_value' => array(
      'rain',
      'sky',
      'temperature',
    ),
  );

  /* TODO template_preprocess_weather_es the full info
    $form['cantidad'] = array(
      '#type' => 'radios',
      '#title' => t('Information'),
      '#options' => array(
        're' => t('Reduced - every 12h or 24h'),
        'fu' => t('Full - every 6h'),
      ),
      '#default_value' => 're',
    );
     */
  $form['save'] = array(
    '#type' => 'submit',
    '#value' => t('Save configuration'),
  );
  $form['add'] = array(
    '#type' => 'submit',
    '#value' => t('Add new location'),
  );
  $form_state['storage']['wid'] = $wid;
  $form['#submit'] = array(
    'weather_es_form_submit',
  );
  $form['#validate'] = array(
    'weather_es_form_validate',
  );
  return $form;
}