Now that our application is starting to accumulate a significant quantity of data, it would be nice to be able to search it. In this section, we'll create an interface for searching addresses and names and displaying the search results. We'll start with a form for defining what the user wants to search for:
Then we'll search and display the results:
The first thing we'll do is create a Search
Controller and then write the database logic for searching.
To do this, we'll create lib/AddressBook/Controller/Search.pm
. We'll have a single action that will generate a search form and then display results when the form is submitted as follows:
package AddressBook::Controller::Search; use Moose; use namespace::autoclean; BEGIN {extends 'Catalyst::Controller'; } extends 'Catalyst::Controller::FormBuilder'; =head1 NAME AddressBook::Controller::Search - Catalyst Controller =head1 DESCRIPTION Catalyst Controller. =head1 METHODS =cut sub search : Global Form { my ($self, $c, $query...