View on
MetaCPAN is shutting down
For details read Perl NOC. After June 25th this page will redirect to
Ken Railey > HTML-DBForm > HTML::DBForm::Search::DropDown



Annotate this POD

View/Report Bugs
Module Version: 1.05   Source  


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.


    $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.




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


syntax highlighting: