config {
    engine          CGI;
    template_engine TT;

    Init            Std             {}
    SQL             SQLite          {}
    SQL             Postgres        {}
    SQL             MySQL           {}
    CGI             Gantry          { with_server 1; gen_root 1; flex_db 1; }
    Control         Gantry          { dbix 1; }
    Model           GantryDBIxClass {}
    SiteLook        GantryDefault   {}
}

app Address {
    config {
        dbconn `dbi:SQLite:dbname=app.db` => no_accessor;
        template_wrapper `genwrapper.tt` => no_accessor;
    }
    controller is base_controller {
        method do_main is base_links {
        }
        method site_links is links {
        }
    }
    table family_address {
        field id {
            is int4, primary_key, auto;
        }
        field ident {
            is             varchar;
            label          Ident;
            html_form_type text;
        }
        field description {
            is             varchar;
            label          Description;
            html_form_type text;
        }
        field created {
            is datetime;
        }
        field modified {
            is datetime;
        }
        foreign_display `%ident`;

    }
    controller FamilyAddress is AutoCRUD {
        controls_table `family_address`;
        rel_location family_address;
        text_description `family address`;
        page_link_label `Family Address`;
        method do_main is main_listing {
            cols ident, description;
            header_options Add;
            row_options Edit, Delete;
            title `Family Address`;
        }
        method form is AutoCRUD_form {
            all_fields_but id, created, modified;
            extra_keys
                legend => `$self->path_info =~ /edit/i ? 'Edit' : 'Add'`;
        }
    }
    table birth_date {
        field id {
            is int4, primary_key, auto;
        }
        field ident {
            is             varchar;
            label          Ident;
            html_form_type text;
        }
        field description {
            is             varchar;
            label          Description;
            html_form_type text;
        }
        field created {
            is datetime;
        }
        field modified {
            is datetime;
        }
        foreign_display `%ident`;
        field family_address {
            is             int4;
            label          `Family Address`;
            refers_to      `family_address`;
            html_form_type select;
        }
    }
    controller BirthDate is AutoCRUD {
        controls_table `birth_date`;
        rel_location birth_date;
        text_description `birth date`;
        page_link_label `Birth Date`;
        method do_main is main_listing {
            cols ident, description;
            header_options Add;
            row_options Edit, Delete;
            title `Birth Date`;
        }
        method form is AutoCRUD_form {
            all_fields_but id, created, modified;
            extra_keys
                legend => `$self->path_info =~ /edit/i ? 'Edit' : 'Add'`;
        }
    }
    table a {
        field id {
            is int4, primary_key, auto;
        }
        field ident {
            is             varchar;
            label          Ident;
            html_form_type text;
        }
        field description {
            is             varchar;
            label          Description;
            html_form_type text;
        }
        field created {
            is datetime;
        }
        field modified {
            is datetime;
        }
        foreign_display `%ident`;

    }
    controller A is AutoCRUD {
        controls_table `a`;
        rel_location a;
        text_description `a`;
        page_link_label `A`;
        method do_main is main_listing {
            cols ident, description;
            header_options Add;
            row_options Edit, Delete;
            title `A`;
        }
        method form is AutoCRUD_form {
            all_fields_but id, created, modified;
            extra_keys
                legend => `$self->path_info =~ /edit/i ? 'Edit' : 'Add'`;
        }
    }
    table b {
        field id {
            is int4, primary_key, auto;
        }
        field ident {
            is             varchar;
            label          Ident;
            html_form_type text;
        }
        field description {
            is             varchar;
            label          Description;
            html_form_type text;
        }
        field created {
            is datetime;
        }
        field modified {
            is datetime;
        }
        foreign_display `%ident`;

    }
    controller B is AutoCRUD {
        controls_table `b`;
        rel_location b;
        text_description `b`;
        page_link_label `B`;
        method do_main is main_listing {
            cols ident, description;
            header_options Add;
            row_options Edit, Delete;
            title `B`;
        }
        method form is AutoCRUD_form {
            all_fields_but id, created, modified;
            extra_keys
                legend => `$self->path_info =~ /edit/i ? 'Edit' : 'Add'`;
        }
    }
    join_table a_b {
        joins a => b;
    }

}
