Gantry

 view release on metacpan or  search on metacpan

lib/Gantry/Docs/FAQ.pod  view on Meta::CPAN

     $self->send_spam( $data->{ blog_id }, $new_row );
 }

You are completely responsible for updating the database in the add_action.
A good model helps with this.

The other actions work similarly.  Note that there is no need to be completely
honest with the names.  It would a good use of L<Gantry::Plugins::CRUD> to
implement do_delete so that it marked rows as invisible rather than deleting
them.  That wouldn't be possible with AutoCRUD.

As a final note, it is not necessary to define all the options for a
L<Gantry::Plugins::CRUD> object.  It is fine to have only delete_action
and the keys it needs.  You may also have different objects for add,
edit, and/or delete.  This gives an easy way for add and edit to use
different forms, for example.

=head2 Can I use AutoCRUD and/or CRUD if I wrote my own models?

This is really two questions.  First, 'Can I use AutoCRUD with hand
written models?'  The answer is: Yes, so long as one of the following
is true of your ORM.  (1) it responds to dbi_commit, create and retrieve
calls, the objects returned by retrieve respond to delete, and -- when your
form is used for editing -- it expects a row object returned by your retrieve.
(2) you implement a helper similar to
Gantry::Plugins::AutoCRUDHelper::DBIxClass.

Second, 'Can I use CRUD if I wrote my own models?'  The answer is: Yes.
For CRUD above restrictions don't apply since it works even if
there is no model.

=head2 How do I control error page appearance?

When something in Gantry dies, the main handler traps the error and
calls custom_error on the site object to generate the error page.
Simply implement your own custom_error to change how the error output
appears to your users.  Note that it is often useful to change from
a developer-friendly version to a user-friendly version as you move
to production.

The custom_error method is invoked on the site object.  It receives
an array of error output lines.

=head2 How can I let my users pick dates easily?

Date entry is controlled by form.tt.  To make it work you need to do
four things, the first two of them in them in your form method:

=over 4

=item 1.

Name your form by including this key in the returned hash:

 name => 'your_name',

=item 2.

Add a javascript key to the returned hash:

 javascript => $self->calendar_month_js( 'your_name' ),

your_name must match the name from step 1.

=item 3.

Add a date_select_text key to the hash of each date field:

 {
     date_select_text => 'Popup Calendar',
     # ...
 }

=item 4.

Add a uses element for Gantry::Plugins::Calendar to the controller:

    controller Name {
        uses Gantry::Plugins::Calendar;
    }

=back

See L<Bigtop::Docs::Tutorial> for how to make these steps happen from bigtop
files.

=head1 How can I use DBIx::Class with Gantry?

There are several things you need to do to use DBIx::Class effectively
with Gantry:

=over 4

=item 1.

Implement your DBIx::Class::Schema class like this:

    package YourApp::Model;
    use strict; use warnings;

    use base 'DBIx::Class::Schema';

    use Gantry::Utils::ModelHelper qw( db_Main );

    __PACKAGE__->load_classes( qw/ list tables here / );

    sub gen_db_Main {
        my $class = shift;
        return sub {
            return $class->db_Main();
        };
    }

    sub get_db_options {
        return { AutoCommit => 1 };
    }

    1;

By using Gantry::Utils::ModelHelper as shown, you can rely on the existing
Gantry database connection scheme (keep reading for details or see



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