我正在尝试为表单呈现表格布局(html 表),以便第一个单元格包含一个复选框。
$form = array();
$res = query('SELECT * FROM {mytable}');
$rows = array();
while($row = db_fetch_array($res)){
$record = array();
$checkbox = array(
'#type' => 'checkbox',
'#attributes' => array(
'value' => $row['id'],
'name' => 'myrecord[]',
),
);
$record[] = drupal_render($checkbox);
$record[] = $row['other_field_1'];
$record[] = $row['other_field_2']
$rows[] = $record;
}
$form['records'] = array(
'#value' => theme('table', array(), $rows);
);
return $form;
但是所有渲染的复选框都有输出
<input type="checkbox" class="form-checkbox" name="" value="1" id="">
<input type="checkbox" class="form-checkbox" name="" value="1" id="">
<input type="checkbox" class="form-checkbox" name="" value="1" id="">
<input type="checkbox" class="form-checkbox" name="" value="1" id="">
名称和值属性未应用于复选框的问题是什么?