Rose::DBx::Garden - bootstrap Rose::DB::Object and Rose::HTML::Form classes


 use Rose::DBx::Garden;
 my $garden = Rose::DBx::Garden->new(
         garden_prefix   => 'MyRoseGarden',    # instead of class_prefix
         perltidy_opts   => '-pbp -nst -nse',  # Perl Best Practices
         db              => My::DB->new, # Rose::DB object
         find_schemas    => 0,           # set true if your db has schemas
         force_install   => 0,           # do not overwrite existing files
         debug           => 0,           # print actions on stderr
         skip_map_class_forms => 1,      # no Form classes for many2many map classes
         include_autoinc_form_fields => 1,
         # other Rose::DB::Object::Loader params here
 # $garden ISA Rose::DB::Object::Loader



Rose::DBx::Garden bootstraps Rose::DB::Object and Rose::HTML::Form based projects. The idea is that you can point the module at a database and end up with work-able RDBO and Form classes with a single method call.

Rose::DBx::Garden inherits from Rose::DB::Object::Loader, so all the magic there is also available here.


NOTE: All the init_* methods are intended for when you subclass the Garden class. You can pass in values to the new() constructor for normal use. See Rose::Object::MakeMethods::Generic.


The default behaviour is to include db columns flagged as auto_increment from the generated Form class and to map them to the 'serial' field type. Set this value to a false value to exclude auto_increment columns as form fields.


Sets the default RDBO column type to RHTMLO field type mapping. Should be a hash ref of 'rdbo' => 'rhtmlo' format.


Returns a CODE ref for filtering a column name to its corresponding form field label. The CODE ref should expect two arguments: the Garden object and the column name.

The default is just to return the column name. If you wanted to return, for example, a prettier version aligned with the naming conventions used in Rose::DB::Object::ConventionManager, you might do something like:

    my $garden = Rose::DBx::Garden->new(
                    column_to_label => sub {
                           my ($garden_obj, $col_name) = @_;
                           return join(' ', 
                                       map { ucfirst($_) }
                                       split(m/_/, $col_name)


The default base class name is MyRoseGarden. This value overrides class_prefix and base_class in the base Loader class.


If set, Perl::Tidy will be called to format all generated code. The value of perltidy_opts should be the same as the command-line options to perltidy.

The default is 0 (no run through Perl::Tidy).


Tie the size and maxlength of text input fields to the allowed length of text columns. Should be set to an integer corresponding to the max size of a text field. The default is 64.


The return value is inserted into the base RDBO class created.


The return value is inserted into the base RHTMLO class created;


The default return value is an empty arrayref, which is interpreted as "all schemas" if the find_schemas flag is true.

Otherwise, you may explicitly name an array of schema names to limit the code generated to only those schemas you want. Must be used with find_schemas set to true.

use_db_name( name )

Define an explicit database name to use when generating class names. The default is taken from the Rose::DB connection information. NOTE:This does not affect the db connection, only the string used in constructing class names.

NOTE:This option is ignored if find_schemas() is true.

plant( path )

path will override module_dir() if set in new().

Returns a hash ref of all the class names created, in the format:

 RDBO::Class => RHTMLO::Class

If no RHTMLO class was created the hash value will be '1'.


An alias for plant().


Returns the garden_prefix() value with which this class was created.

garden_default_field( column, label, tabindex )

Returns the Perl code text for creating a generic Form field.

garden_numeric_field( column, label, tabindex )

Returns the Perl code text for creating a numeric Form field.

garden_boolean_field( column, label, tabindex )

Returns the Perl code text for creating a boolean Form field.

garden_text_field( column, label, tabindex )

Returns the Perl code text for creating a text Form field.

garden_textarea_field( column, label, tabindex )

Returns Perl code for textarea field.

garden_hidden_field( column, label, tabindex )

Returns the Perl code text for creating a hidden Form field.

garden_serial_field( column, label, tabindex )

Returns the Perl code text for creating a serial Form field.


Peter Karman, <karman at>


Please report any bugs or feature requests to bug-rose-dbx-garden at, or through the web interface at I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.


You can find documentation for this module with the perldoc command.

    perldoc Rose::DBx::Garden

You can also look for information at:


Thanks to Adam Prime, at for patches and feedback on the design.

The Minnesota Supercomputing Institute sponsored the development of this software.


Copyright 2007 by the Regents of the University of Minnesota.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.