Bigtop
view release on metacpan or search on metacpan
lib/Bigtop/Docs/Tutorial.pod view on Meta::CPAN
html_form_type text;
}
field my_companies {
is int4;
label `My Company`;
refers_to my_companies;
html_form_type select;
}
Because we used the -> notation when running bigtop originally, the
foreign key fields are already present. But here is how to add one
manually: use the refers_to statement to say which table it points to.
Note that it must point to the primary key of the other table and we
generally assume that the key will be the unique id column.
Bigtop::Backend::SQL::Postgres does not currently (nor is it ever likely
to) generate genuine SQL foreign keys. If you want foreign
keys, and your database supports them, consider implementing your own SQL
backend to generate the SQL code for them.
Note that when we used bigtop, it chose the foreign key column names
to match the foreign table names exactly. Our original data model
diagram used slightly different names. If you want the bigtop file
to match the picture, change the names of the foreign key fields.
The Gantry html_form_type for foreign key columns is C<select> which
allows the user to pick one item from a pull down list.
field customers {
is int;
label Customer;
refers_to customers;
html_form_type select;
}
field invoices {
is int;
label `Invoice Number`;
refers_to invoices;
html_form_type select;
}
field hours {
is int;
label Hours;
html_form_type text;
}
field charge_per_hour {
is int;
label Rate;
html_form_type text;
}
field notes {
is text;
label `Notes to Customer`;
html_form_type textarea;
html_form_optional 1;
html_form_rows 4;
html_form_cols 50;
}
You can affect the eventual appearance of the field on HTML forms with
various statements. Here are two that affect textareas: html_form_rows
and html_form_cols; take a wild guess at what they do. There is one
gotcha for text input boxes. Since Template Toolkit uses a lot of magic
while dereferencing, to set the size of a text input box use
html_form_display_size.
field description {
is text;
label `Notes to Self`;
html_form_type textarea;
html_form_optional 1;
html_form_rows 4;
html_form_cols 50;
}
}
sequence invoices_seq {}
table invoices {
sequence invoices_seq;
foreign_display `%number`;
field id { is int4, primary_key, assign_by_sequence; }
field number {
is int;
label Number;
html_form_type text;
}
field status {
is int;
label Status;
refers_to status;
html_form_type select;
}
field sent {
is date;
label `Sent On`;
date_select_text `Popup Calendar`;
html_form_type text;
html_form_optional 1;
}
field paid {
is date;
label `Paid On`;
date_select_text `Popup Calendar`;
html_form_type text;
html_form_optional 1;
}
field company_id {
is int;
label `My Company`;
refers_to my_companies;
html_form_type select;
}
field customer_id {
is int;
label Customer;
refers_to customers;
html_form_type select;
}
field notes {
is text;
label `Notes to Customer`;
html_form_type textarea;
( run in 0.489 second using v1.01-cache-2.11-cpan-39bf76dae61 )