我在 Drupal 中使用 time_tracker_simple 模块。当有人从下拉列表中选择并点击提交时,它会停留在同一页面上,但不会保留该值。选择后如何保留下拉列表的值。
下面是模块中使用的代码。
function time_tracker_simple_timer_form($form_state) {
global $user;
$active_timer = _time_tracker_simple_get_timer();
//*** Both start and start buttons must actually be on the form for #submit to work correctly
$form['stop'] = array(
'#value' => t('Stop'),
'#type' => 'submit',
'#weight' => 20,
'#access' => FALSE,
'#button_type' => 'timer_control_stop',
'#submit' => array('time_tracker_simple_timer_stop'),
);
$form['start'] = array(
'#value' => t('Start'),
'#type' => 'submit',
'#access' => FALSE,
'#weight' => 20,
'#submit' => array('time_tracker_simple_timer_start'),
'#button_type' => 'timer_control_start',
);-----This part is the drop down list------
$activities = array();
$activities[] = '(none)';
$results = db_query("SELECT * FROM {time_tracker_activity} ORDER BY weight ASC");
while ($result = db_fetch_object($results)) {
$activities[$result->taid] = $result->name;
}
if (count($activities) > 1) {
// The activity choser
$form['activity'] = array(
'#title' => t('Activity'),
'#type' => 'select',
'#weight' => 5,
'#options' => $activities,
);
}