我想验证从选择选项中选择的公司名称 - “公司”
当我尝试$form_values['submitted_tree']['company_1'];
时,它会给我提供密钥而不是字符串值。例如。$form_values['submitted_tree']['company_1'];
显示'1',这是所选选项的关键。
我试过这个,但它仍然打印键'1'而不是它的值。
<?php
$_page_num = $form_state['values']['details']['page_num'];
$key1 = $form_state['values']['submitted_tree']['company_1'];
$value1 = $form['submitted_tree']['company_1']['#options'][$key1];
$key2 = $form_state['values']['submitted_tree']['company_2'];
$value2 = $form['submitted_tree']['company_2']['#options'][$key2];
if (($_page_num == 2) && ($value1 == $value2))
{
drupal_set_message(print_r($form['submitted_tree']['company_2']['#options'][$key2]));
}
?>
我用来填充select选项的代码是
$array = array();
if ($_SESSION['major'] == 0) {
$sql = db_query("Select data from webform_submitted_data where nid = 2133 and cid = 20 and sid in (SELECT sid FROM webform_submitted_data WHERE nid = 2133 and cid =30 and no = 0) and data not in (SELECT data FROM webform_submitted_data where nid = 2134 and cid=15 group by data having COUNT(*) > 6) order by data ASC");
while($row = db_fetch_object($sql)) {
$array[] = $row->data;
}
}
return $array;
任何人都可以帮我检索所选的选项中显示的实际文本值。我也尝试过form_state,但它会返回相同的结果。
答案 0 :(得分:0)
即使我前一段时间遇到过这个问题。您始终可以在验证功能中再次运行用于再次填充选择选项的查询。您知道密钥,您也可以找到所选元素的值。 希望这有帮助!