HTML::DBForm::Search::DropDown - Creates a web interface for searching database tables
$search = HTML::DBForm::Search->new('dropdown', { column => 'name' }); $editor->run(search => $search);
HTML::DBForm::Search::DropDown provides a web interface to search for rows in a database to be updated by HTML::DBForm.
Constructor inherited from HTML::DBForm::Search
takes a scalar indicating the type of search module to create (in this case 'dropdown'), and a list of hash refs designating which columns to display as HTML select form elements, and in which order.
Each hash should have one of the following keys: 'column', 'columns', or 'sql'. 'column' should be the db column to search, 'columns' should be two db columns, the first of which will be the column to search, and the second of which will be the values to display as option labels. 'sql' can be used to populate the select options with an arbitrary SQL statement. If one column is returned from the SQL statement, then it will be used as choice values and lables. If two columns are returned, then the first will be the specified column value, while the second will be used as option labels.
Example
$search = HTML::DBForm::Search->new('dropdown', { column => 'category' }, { columns => ['id', ' CONCAT(fname, ' ', lname) '] } );
This would create a two step search, the first screen would be a selection of existing categories, and the next screen would be a selection of names within the chosen categories. When picking columns to display in the search, be aware that the final choice should result in the primary key being chosen.
$search = HTML::DBForm::Search->new('dropdown', { sql => ['id','SELECT id, label FROM table ORDER BY label'] } );
This would create a simple one step search.
You can use as many hashrefs as needed, each one will generate a new search step, (e.g three hash references will create a three step search). Just keep in mind that the last column chosen must be the column given to DBForm->new() as a primary key.
Sets an optional css file
Takes a scalar holding the path to a stylesheet.
$search->set_stylesheet('/styles/site_styles.css');
Sets an optional template file
Takes a scalar holding the path to an HTML::Template template.
To get a template file to start with, you can do this: perl -MHTML::DBForm::Search::DropDown -e 'print HTML::DBForm::Search::DropDown::TEMPLATE()' > sample.tmpl
$search->set_template('/www/templates/my.tmpl');
1 POD Error
The following errors were encountered while parsing the POD:
You forgot a '=back' before '=head2'
To install HTML::DBForm, copy and paste the appropriate command in to your terminal.
cpanm
cpanm HTML::DBForm
CPAN shell
perl -MCPAN -e shell install HTML::DBForm
For more information on module installation, please visit the detailed CPAN module installation guide.