Simple, but more flexible, CRUD

I've wrote last year about my Dancer::Plugin::SimpleCRUD, which offers simple and easy automatic CRUD operations for Dancer apps.

So, if you don't know about it yet, have a read of that post first; there seems no point in duplicating its content here.

So, what's new?

A quick rundown of some of the useful new features added to the SimpleCRUD plugin this year, by myself and contributors:

  • custom_columns feature

    Courtesy of Michael J South (msouth), this new feature allows the record listing screen to include custom columns, built up using SQL statements if required or simple column names, with transformations to be passed to HTML::Table::FromDatabase to transform the contents easily (for instance, wrapping email addresses/URLs in anchor tags, formatting, etc).

  • add_edit_row hook

    A new feature suggested / requested by Rene on IRC; a hook which fires right before a new row is created / an existing row is edited, letting you massage the data before it hits the database.

  • basic foreign key support

    A new option to let you specify that certain columns are foreign keys, and describe which table they refer to, and which columns in the foreign table should be used as the key and the label, respectively.

    For an example, from the example app shipped with the plugin (some settings omitted for brevity, see the full config on GitHub:

    simple_crud(
        db_table => 'people',
        ...
        foreign_keys => {
            employer_id => {
                table        => 'employer',
                key_column   => 'id',
                label_column => 'name',
            },
        },
        ...
    );

    The above example means that the column employer_id in the people table refers to the key column id of the employer table, and that the name column of the employer table should be used for the labels when selecting a user's employer when adding/editing records.

    In a future version, it may be possible for this to be done automatically by inspecting the database schema, but I'm not sure how it could decide which column(s) of the foreign table is the human-friendly name/description/whatever.

  • new input_types option

    Default form field types are selected automatically, and will usually be appropriate, but the input_types option lets you override the default choices if you wish.

  • auto_pretty_headers

    Uses a new feature in HTML::Table::FromDatabase, auto_pretty_headers, to automatically make table headers prettier when displaying records - for instance, first_name would become First Name.

  • various bugfixes

    Various bug fixes, including issues if the prefix changes after the simple_crud call, and working properly with named database connections.

Many thanks to the contributors mentioned above for their valued contributions!

Sorry for lateness...

Unfortunately, work, personal commitments and hangovers conspired against me, and I ended up being late writing this post. Sorry.

AUTHOR

David Precious (bigpresh)