config {
engine CGI;
template_engine TT;
Init Std {}
CGI Gantry { with_server 1; flex_db 1; gen_root 1; }
SQL SQLite {}
Conf General {}
Control Gantry { dbix 1; }
Model GantryDBIxClass {}
SiteLook GantryDefault {}
}
app Apps::AddressBook {
authors `Phil Crow` => `philcrow2000@yahoo.com`;
config {
dbconn `dbi:SQLite:dbname=address` => no_accessor;
dbuser apache => no_accessor;
template_wrapper `genwrapper.tt` => no_accessor;
}
table address {
foreign_display `%name`;
field id { is int4, primary_key, auto; }
field name {
is varchar;
label Name;
html_form_type text;
}
field street {
is varchar;
label Street;
html_form_type text;
html_form_optional 1;
}
field city {
is varchar;
label City;
html_form_type text;
html_form_optional 1;
}
field state {
is varchar;
label State;
html_form_type text;
html_form_optional 1;
}
field zip {
is varchar;
label Zip;
html_form_type text;
html_form_optional 1;
html_form_constraint `qr{^\d{5}$}`;
}
field phone {
is varchar;
label Number;
html_form_type text;
}
field email {
is varchar;
label `Email Address`;
html_form_type text;
html_form_optional 1;
}
}
table birth {
field id { is int4, primary_key, auto; }
field name {
is varchar;
label Name;
html_form_type text;
}
field family {
is int4;
label Family;
html_form_type select;
refers_to address;
}
field birthday {
is date;
label Birthday;
html_form_type date;
date_select_text `Popup Calendar`;
}
}
controller Address is AutoCRUD {
controls_table address;
rel_location address;
text_description `address`;
page_link_label Address;
method do_main is main_listing {
title `Address`;
cols name, phone;
header_options Add;
row_options Edit, Delete;
}
method form is AutoCRUD_form {
form_name address;
all_fields_but id;
extra_keys
legend => `$self->path_info =~ /edit/i ? 'Edit' : 'Add'`;
}
}
controller Birth is AutoCRUD {
controls_table birth;
rel_location birthday;
uses Gantry::Plugins::Calendar;
text_description `birthday`;
page_link_label Birthdays;
method do_main is main_listing {
title `Birthday`;
cols name, family, birthday;
header_options Add;
row_options Edit, Delete;
}
method form is AutoCRUD_form {
form_name birthday_form;
all_fields_but id;
extra_keys
javascript => `$self->calendar_month_js( 'birthday_form' )`,
legend => `$self->path_info =~ /edit/i ? 'Edit' : 'Add'`;
}
}
}