$name, '!capacity' => $capacity)); $room_options[$key] = $value; if ($first) { $room_default = $key; $first = FALSE; } } ksort($room_options); // Defaults. if ($selected_category) { $room_default = 'room ' . $selected_category; } foreach ($dates as $day) { if ($day['selected']) { $date_default = $day['month-number'] . '/' . $day['day']; break; } } // Form. $form['date'] = array( '#title' => t('View a Different Day'), '#type' => 'select', '#options' => $date_options, '#default_value' => $date_default, '#weight' => 10, ); $form['room'] = array( '#title' => t('View a Different Room'), '#type' => 'select', '#options' => $room_options, '#default_value' => $room_default, '#weight' => 20, ); $form['submit'] = array( '#type' => 'submit', '#value' => t('Change Day or Room'), '#weight' => 30, ); return $form; } /** * Form submission for the change date form. * * @param string $form_id * Drupal form id. * @param array $form_state * Drupal form state object. */ function room_reservations_select_room_date_form_submit($form_id, &$form_state) { $date = $form_state['values']['date']; $room = drupal_substr($form_state['values']['room'], 5); $redirect = "room_reservations/" . $date . "/" . $room; $form_state['redirect'] = $redirect; }