You are here

function weather_es_configuration in Weather_es 5

Same name and namespace in other branches
  1. 6 weather_es.module \weather_es_configuration()

Show a configuration page for a custom weather_es block

1 string reference to 'weather_es_configuration'
weather_es_menu in ./weather_es.module
Implementation of hook_menu().

File

./weather_es.module, line 164
Non-displayable characters.

Code

function weather_es_configuration($wuid, $form_values = NULL) {
  if (!isset($form_values)) {
    $step = 1;
  }
  else {

    /* This commented lines are to show a Back button
       if ($_POST['op'] == t('Back')) {
         $step = $form_values['step'] - 1;
       }
       else {
         $step = $form_values['step'] + 1;
       }
       */
    $step = $form_values['step'] + 1;
  }
  $form['step'] = array(
    '#type' => 'hidden',
    '#value' => $step,
  );
  switch ($step) {
    case 1:

      // Page 1
      $form['provincia'] = array(
        '#type' => 'fieldset',
        '#title' => t('Select a province'),
        '#collapsible' => TRUE,
        '#collapsed' => FALSE,
        '#tree' => TRUE,
      );
      $form['provincia']['seleccionada'] = array(
        '#type' => 'select',
        '#title' => t('Province'),
        '#default_value' => 00,
        '#options' => _weather_es_provincies(),
        '#description' => t('Province of the city'),
      );
      break;
    case 2:

      // Show page 2
      $form['poblacion'] = array(
        '#type' => 'fieldset',
        '#title' => t('Select a city'),
        '#collapsible' => TRUE,
        '#collapsed' => FALSE,
        '#tree' => TRUE,
      );
      $form['poblacion']['seleccionada'] = array(
        '#type' => 'select',
        '#title' => t('City'),
        '#options' => _weather_es_cities($form_values['provincia']['seleccionada']),
        '#description' => t('City to show the forecast'),
      );
      $form['idioma'] = array(
        '#type' => 'radios',
        '#title' => t('Languages'),
        '#options' => array(
          'es' => t('Spanish'),
          'ca' => t('Catalan'),
          'eu' => t('Euskera'),
          'gl' => t('Gallego'),
          'en' => t('English'),
          'fr' => t('French'),
        ),
        '#description' => t('Choose the language you will see the weather data.'),
        '#default_value' => 'es',
      );
      $form['save'] = array(
        '#type' => 'submit',
        '#value' => t('Save configuration'),
      );
      $form['add'] = array(
        '#type' => 'submit',
        '#value' => t('Add new location'),
      );
      $form['wuid'] = array(
        '#type' => 'value',
        '#value' => $wuid,
      );

      /*
      $form['back'] = array(
      '#type' => 'button',
      '#value' => t('Back')
      );
      */
      break;
  }
  $form['next'] = array(
    '#type' => 'button',
    '#value' => t('Next'),
  );

  // Hide the button at last step
  if ($step >= 2) {
    $form['next'] = array(
      '#type' => 'hidden',
    );
  }

  // This part is important!
  $form['#multistep'] = TRUE;
  $form['#redirect'] = FALSE;
  return $form;
}