Ken Railey > HTML-DBForm > HTML::DBForm::Search::DropDown

Download:
HTML-DBForm-1.05.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 1.05   Source  

NAME ^

HTML::DBForm::Search::DropDown - Creates a web interface for searching database tables

SYNOPSIS ^

    $search = HTML::DBForm::Search->new('dropdown', { column => 'name' });
    
    $editor->run(search => $search);

INTRODUCTION ^

  HTML::DBForm::Search::DropDown provides a web interface to search for rows
  in a database to be updated by HTML::DBForm. 

METHODS ^

new

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.

Example

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

set_stylesheet

Sets an optional css file

Takes a scalar holding the path to a stylesheet.

Example

  $search->set_stylesheet('/styles/site_styles.css');

set_template

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

Example

  $search->set_template('/www/templates/my.tmpl');
syntax highlighting: