Bigtop

 view release on metacpan or  search on metacpan

lib/Bigtop/Docs/Tutorial.pod  view on Meta::CPAN

            paged_conf listing_rows

where listing_rows is the name of an accessor on your site object (usually
that accessor is generated by defining a conf variable of the same name
in the app level config block:

    config {
        #...
        listing_rows 15;
    }

The simple statements in a main_listing method block are:

=over 4

=item title

what appears in the browser window title bar.

=item cols

which columns to show in the output.

=item header_options

links which appear at the far right of the title bar.  Here we allow
the user to add new statuses.

=item row_options

links which appear at the far right of each row in the table.  Here
we allow users to edit the row and to delete it.

=back

        method form is AutoCRUD_form {
            form_name        status;
            fields           name, description;
            extra_keys
                legend => `$self->path_info =~ /edit/i ? 'Edit'
                                                       : 'Add'`;
        }
    }

One of my favorite features of gantry (probably because I wrote it) is
its automated Create, Retrieve, Update, and Delete.  All you have to
do to get it is use Gantry::Plugins::AutoCRUD and implement a method
called form, which returns a specially crafted hash describing the
the appearance of the input form along with populating its fields as
appropriate.  Bigtop::Backend::Control::Gantry can generate the proper
form method as shown here.

There are three statements in an AutoCRUD_form method block:

=over 4

=item form_name

the name of the html form element.  This doesn't usually matter.
It does matter when you use the date popups (see later tables that
have dates).  Note that XHTML does not allow form elements to have names,
but until we fix our date scheme, we'll have to be in violation.

=item fields

a comma separated list of fields that should be included on the form.

=item extra_keys

any extra keys that should be included in the hash form returns and their
values.  The values will not be modified in any way, simply include valid
Perl code in backquotes.  Gantry's form.tt surrounds the entry elements
with a fieldset.  The legend shown here is the legend of that fieldset.

=back

    controller Company is AutoCRUD {
        controls_table   my_companies;
        rel_location     company;
        text_description company;
        page_link_label  Companies;
        method do_main is main_listing {
            title            `My Companies`;
            cols             name, contact_phone;
            header_options   Add;
            row_options      Edit, Delete;
        }
        method form is AutoCRUD_form {
            form_name        company;
            all_fields_but   id;
            extra_keys
                legend     => `$self->path_info =~ /edit/i ? 'Edit' : 'Add'`;
        }
    }

While we can list the fields we want in an AutoCRUD_form, we can also
use all_fields_but and list the fields we don't want.

    controller Customer is AutoCRUD {
        controls_table   customers;
        rel_location     customer;
        text_description customer;
        page_link_label  Customers;
        method do_main is main_listing {
            title            `Customers`;
            cols             name, contact_name, contact_phone;
            header_options   Add;
            row_options      Edit, Delete;
        }
        method form is AutoCRUD_form {
            form_name        customer;
            all_fields_but   id;
            extra_keys
                legend     => `$self->path_info =~ /edit/i ? 'Edit' : 'Add'`;
        }
    }
    controller LineItem is AutoCRUD {
        controls_table   line_items;
        rel_location     lineitem;
        uses             Gantry::Plugins::Calendar;
        text_description `line item`;



( run in 1.494 second using v1.01-cache-2.11-cpan-ceb78f64989 )