I am trying to render a tabular layout (html table) for a form such that first cell contains a checkbox.
$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;
But all the rendered checkbox has output
<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="">
What is the issue that name and value attributes are not getting applied on checkboxes?