Maypole::Model:CDBI::AsForm

Maypole::Model:CDBI::AsForm module can produce HTML form elements for database columns.
Download

Maypole::Model:CDBI::AsForm Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Peter Speltz and Aaron Trevena
  • Publisher web site:
  • http://search.cpan.org/~teejay/Maypole-2.111/lib/Maypole/Model/CDBI/AsForm.pm

Maypole::Model:CDBI::AsForm Tags


Maypole::Model:CDBI::AsForm Description

Maypole::Model:CDBI::AsForm module can produce HTML form elements for database columns. Maypole::Model:CDBI::AsForm module can produce HTML form elements for database columns.SYNOPSIS package Music::CD; use Maypole::Model::CDBI::AsForm; use base 'Class::DBI'; use CGI; ... sub create_or_edit { my $self = shift; my %cgi_field = $self->to_cgi; return start_form, (map { "$_: ". $cgi_field{$_}->as_HTML." " } $class->Columns), end_form; } . . . # Somewhere else in a Maypole application about beer... $beer->to_field('brewery', 'textfield', { name => 'brewery_id', value => $beer->brewery, # however, no need to set value since $beer is object }); # Rate a beer $beer->to_field(rating => select => { items => , }); # Select a Brewery to visit in the UK Brewery->to_field(brewery_id => { items => , }); # Make a select for a boolean field $Pub->to_field('open' , { items => }); $beer->to_field('brewery', { selected => $beer->brewery, # again not necessary since caller is obj. }); $beer->to_field('brewery', 'link_hidden', {r => $r, uri => 'www.maypole.perl.org/brewery/view/'.$beer->brewery}); # an html link that is also a hidden input to the object. R is required to # make the uri unless you pass a uri ##################################################### # Templates Usage < form .. > ... < label > < span class="field" > : < /span > < /label > . . . < label > < span class="field" > Brewery : < /span > < /label > . . . < /form > ##################################################### # Advanced Usage # has_many select package Job; __PACKAGE__->has_a('job_employer' => 'Employer'); __PACKAGE__->has_a('contact' => 'Contact') package Contact; __PACKAGE__->has_a('cont_employer' => 'Employer'); __PACKAGE__->has_many('jobs' => 'Job', { join => { job_employer => 'cont_employer' }, constraint => { 'finshed' => 0 }, order_by => "created ASC", } ); package Employer; __PACKAGE__->has_many('jobs' => 'Job',); __PACKAGE__->has_many('contacts' => 'Contact', order_by => 'name DESC', ); # Choose some jobs to add to a contact (has multiple attribute). my $job_sel = Contact->to_field('jobs'); # Uses constraint and order by # Choose a job from $contact->jobs my $job_sel = $contact->to_field('jobs'); 1; Requirements: · Perl


Maypole::Model:CDBI::AsForm Related Software