By mpapet on
Drupal's 7's tableselect renders a nice table with a checkbox control column appended.
Here's what to do if you don't need a check box using a pretty plain form.
I've skipped all of the menu stuff, this is the function that defines your form.
function example_make_form() {
$form['#attached']['css'] = array (
drupal_get_path('module', 'cg_volunteer') . '/cg_admin.css',
);
$form['add_contact'] = array(
'#prefix' => '<div id = "whole_table">',
'#type' => 'fieldset',
'#title' => t('Add Contact'),
);
$form['add_contact']['cg_f_name'] = array(
'#prefix' => '<div id = "one_row><div id = "one_cell">',
'#type' => 'textfield',
'#title' => t('First Name '),
'#maxlength' => 20,
'#suffix' => '</div>',
);
$form['add_contact']['cg_l_name'] = array(
'#prefix' => '<div id = "one_cell">',
'#type' => 'textfield',
'#title' => t('last name'),
'#maxlength' => 20,
'#suffix' => '</div></div></div>',
);
}
The css file has the following:
#whole_table {
display:table;
width: 100%;
border-spacing: 10px;
}
#one_row {
display: table-row;
}
#one_cell {
display: table-cell;
}
Nice!
The only question remaining is, how many browsers support those css features?