我在代码中有以下内容:
$form['location'] = array(
'#value' => '<select name="location">
<option value="778">Location1 </option>
<option value="779">Location2 </option>
<option value="780">Location3 </option>
<option value="781">Location4 </option>
</select>',
);
在提交功能中,如何访问在选择框中选择的值?
$form_state['values']['location']
不起作用:(
答案 0 :(得分:4)
这不是你在Drupal中的表现。在尝试在Drupal中创建表单之前阅读this
这就是选择元素的样子:
$form['feed'] = array(
'#type' => 'select',
'#title' => t('Display of XML feed items'),
'#default_value' => variable_get('feed_item_length','teaser'),
'#options' => array(
'title' => t('Titles only'),
'teaser' => t('Titles plus teaser'),
'fulltext' => t('Full text'),
),
'#description' => t('Global setting for the length of XML feed items that are output by default.'),
);
答案 1 :(得分:3)