【发布时间】:2015-05-26 21:17:12
【问题描述】:
大家好,我真的是 Drupal 的新手,现在我从我的数据库中选择了我需要的所有数据并将其显示在下拉列表中。 不幸的是,我不知道如何使用这个特定的选定字段更新我的数据库,因为我没有任何价值......
$options = array();
foreach ($results as $result) {
$options["name"] = array(
$result->name,
);
}
$options2 = array();
foreach ($results_tour as $result2) {
$options2[$result2->sku] = array(
$result2->title,
);
}
$form['tour'] = array(
'#type' => 'select',
'#options' => $options2,
);
$form['tour_guide'] = array(
'#type' => 'select',
'#title' => t('Tour Guide'),
'#options' => $options,
'#description' => 'Please select a guide for this specific tour'
);
$form['save'] = array(
'#type' => 'submit',
'#value' => 'Speichern',
'#submit' => array('plantours_form_submit'),
);
return $form;
}
function plantours_form_submit($form, $form_state) {
db_update('commerce_line_item')
->fields(array(
'status' => $options["name"]
))
->execute();
}
【问题讨论】:
标签: database forms select drupal drupal-7