我需要输出一个带有其他内容的drupal表单。这是我的代码:
$outputs="something else";
$outputs.=render(drupal_get_form(quotes_form));
function quotes_form(){
$form = array();
$form['arrival_city_1'] = array(
'#default_value' => 'Finland',
'#type' => 'select',
'#required' => TRUE,
'#options'=>array(
'China' => 'China',
'Finland' => 'Finland',
),
'#weight'=>2,
'#suffix'=>'</div>',
);
return $form;
}
值“Filand”应为默认值。但是,我检查html输出:
<select id="edit-arrival-city-1" class="form-select required" name="arrival_city_1">
<option value="China">China</option>
<option selected="selected" value="Finland">Finland</option>
</select>
所选值在代码中是正确的,但“中国”显示在列表字段中。谁知道为什么?感谢
答案 0 :(得分:0)
下面的代码用于复选框。您可以轻松创建选择框。
$node_schema_type = array('micro_data','json_ld');
foreach($node_schema_type as $key => $value ){
print $sch_type[$key] = $value;
}
$form['schema_format'] = array(
'#type' => 'checkboxes',
'#options' => drupal_map_assoc(array('micro_data','json_ld')),
'#default_value' => $sch_type,
'#title' => t('Add schema type'),
);
谢谢!