| 1 |
$Id: README.txt,v 1.1.2.1 2008/03/01 17:19:05 usonian Exp $
|
| 2 |
|
| 3 |
The Form Table module provides two new Form API elements and theme functions
|
| 4 |
which make it easier to format Form elements within HTML tables.
|
| 5 |
|
| 6 |
The new element types are:
|
| 7 |
|
| 8 |
* `formtable`
|
| 9 |
* `formrow`
|
| 10 |
|
| 11 |
Both behave similarly to the `fieldset` element; you declare a `formtable`
|
| 12 |
element, then declare `formrow` elements as children of the `formtable`,
|
| 13 |
and finally you declare your standard form items as children of your
|
| 14 |
`formrow` elements, using the '#prefix' and '#suffix' attributes to add
|
| 15 |
opening and closing `<td>` tags.
|
| 16 |
|
| 17 |
The `formtable` element accepts the following attributes:
|
| 18 |
* #attributes
|
| 19 |
* #title
|
| 20 |
* #description
|
| 21 |
* #caption
|
| 22 |
* #children
|
| 23 |
* #header - an array of column header strings
|
| 24 |
|
| 25 |
The `formrow` element accepts the following attributes:
|
| 26 |
* #attributes
|
| 27 |
* #children
|
| 28 |
|
| 29 |
(For zebra tables, set the 'class' attribute to 'even' and 'odd' for alternating rows.)
|
| 30 |
|
| 31 |
##Usage
|
| 32 |
|
| 33 |
<?php
|
| 34 |
|
| 35 |
$form['mytable'] = array(
|
| 36 |
'#type' => 'formtable',
|
| 37 |
'#title' => t('Previous Experience'),
|
| 38 |
'#description' => t('Please tell us about previous positions you have held.'),
|
| 39 |
'#header' => array(t('Title'), t('Company'), t('Salary'))
|
| 40 |
);
|
| 41 |
|
| 42 |
$form['mytable']['row1'] = array(
|
| 43 |
'#type' => 'formrow'
|
| 44 |
);
|
| 45 |
|
| 46 |
$form['mytable']['row1']['title1'] = array(
|
| 47 |
'#type' => 'textfield',
|
| 48 |
'#size' => 20,
|
| 49 |
'#prefix' => '<td>',
|
| 50 |
'#suffix' => '</td>'
|
| 51 |
);
|
| 52 |
|
| 53 |
$form['mytable']['row1']['company1'] = array(
|
| 54 |
'#type' => 'textfield',
|
| 55 |
'#size' => 20,
|
| 56 |
'#prefix' => '<td>',
|
| 57 |
'#suffix' => '</td>'
|
| 58 |
);
|
| 59 |
|
| 60 |
$form['mytable']['row1']['salary1'] = array(
|
| 61 |
'#type' => 'textfield',
|
| 62 |
'#size' => 20,
|
| 63 |
'#prefix' => '<td>',
|
| 64 |
'#suffix' => '</td>'
|
| 65 |
);
|
| 66 |
|
| 67 |
$form['mytable']['row2'] = array(
|
| 68 |
'#type' => 'formrow',
|
| 69 |
'#prefix' => '<td>',
|
| 70 |
'#suffix' => '</td>'
|
| 71 |
);
|
| 72 |
|
| 73 |
$form['mytable']['row2']['title2'] = array(
|
| 74 |
'#type' => 'textfield',
|
| 75 |
'#size' => 20,
|
| 76 |
'#prefix' => '<td>',
|
| 77 |
'#suffix' => '</td>'
|
| 78 |
);
|
| 79 |
|
| 80 |
$form['mytable']['row2']['company2'] = array(
|
| 81 |
'#type' => 'textfield',
|
| 82 |
'#size' => 20,
|
| 83 |
'#prefix' => '<td>',
|
| 84 |
'#suffix' => '</td>'
|
| 85 |
);
|
| 86 |
|
| 87 |
$form['mytable']['row2']['salary2'] = array(
|
| 88 |
'#type' => 'textfield',
|
| 89 |
'#size' => 20,
|
| 90 |
'#prefix' => '<td>',
|
| 91 |
'#suffix' => '</td>'
|
| 92 |
);
|
| 93 |
|
| 94 |
/* Et Cetera */
|
| 95 |
|
| 96 |
?>
|
| 97 |
|
| 98 |
(For a long table you would probably want to just use a loop to generate
|
| 99 |
all of the rows and fields, assuming they're sequentially named.)
|
| 100 |
|
| 101 |
##Credits
|
| 102 |
Written & Maintained by Andy Chase <http://proofgroup.com>
|