AsFormImproved

[prev] [thread] [next] [Date index for 2004/12/10]

From: Peter Speltz
Subject: AsFormImproved
Date: 08:40 on 10 Dec 2004
--0-1316208330-1102668006=:36276
Content-Type: text/plain; charset=us-ascii
Content-Id: 
Content-Disposition: inline

Here's a version of AsForm I've been working on. Its finally complete enough
for my apps.  Tony (or whoever maintains this) , please look at it and see what
you think of these changes. 

Briefly it does to_select without object creation, makes selects for enum
columns, bool columns.  allows you to get inputs for has_a classess instead of
a select box every time (which can get quite annoying when a new customer has_a
phone number, address, and email. :) ). You can limit the selections for
to_select with a sql limiting clause. You can specify which columns to use in
select box. You can use your own column_type sub (which becomes important when
you find out the default one doesn't work). You can get types for is_a columns
(with column_type sub :) ) and maybe more.

I gave a good first run at documenting it . I couldn't get the example formate
good so i'm attaching it and posting it on Maypole wiki along with the code.
see CHANGES and GETTING SPECIFIC IN MODEL CLASS in pod for some details.


thanks

=====
pjs


		
__________________________________ 
Do you Yahoo!? 
Yahoo! Mail - Helps protect you from nasty viruses. 
http://promotions.yahoo.com/new_mail
--0-1316208330-1102668006=:36276
Content-Type: text/plain; name="AsFormImproved.example"
Content-Description: AsFormImproved.example
Content-Disposition: inline; filename="AsFormImproved.example"

# Big Example with AsForm.pm Improved
# ********* NOT TESTED **************

# MYSQL schema

CREATE TABLE cd (
	cdid INT NOT NULL AUTO_INCREMENT,
	genre ENUM('Rock','Dance','Punk') NULL,
	hardcopy BOOL NULL,
	copy_protection BOOL NULL,
	location INTEGER UNSIGNED NULL,
	language VARCHAR(50) NULL,
	PRIMARY KEY(cdid)
);

CREATE TABLE location (
	locid INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
	row CHAR(2) NULL,
	shelf CHAR(2) NULL,
	PRIMARY KEY(locid)
);

CREATE TABLE rip (
	ripid INTEGER UNSIGNED NOT NULL,
	format VARCHAR(10) NOT NULL,
	quality VARCHAR(10) NOT NULL,
	PRIMARY KEY(ripid)
);
	
	package Music::DBI;
	use Class::DBI::AsForm;	
	use base Class::DBI;
	...

	# Define decent column_type until Class::DBI::Column::Type is finished 
	sub column_type {
		my $class = shift;
		my $type =  $class->_column_info->{$col}->{type} || # check is_a
					eval{$class->isa_class($col)->column_type($col)}; 
		if ($type =~ /^tinyint\(1\)$/i) {
			$type = "BOOL"; # same as "Bool('No', 'Yes') 
		}
		$type;
	}
		
	# Method to get class of is_a inherited columns
	# Needed to get proper column type 
	sub isa_class {
		my ($class, $col) = @_;
		die "Need a column for isa_class." unless $col;
		my ($isaclass, $exists) = ();
		eval {
			my $isa = $class->meta_info("is_a");
			foreach ( keys %$isa ) {
				$isaclass = $isa->{$_}->foreign_class;
				$exists = $isaclass->find_column($col);
				last if $exists;
			}
		};
		$exists ? return $isaclass : return undef;
	}
    ...

	package Music::CD;
	use base Music::DBI;
	...
	__PACKAGE__->columns(qw/cdid genre copy_protection hardcopy location language /);
	__PACKAGE__->has_a(location => Music::Location);  
	...

	sub has_a_new { { location => [qw/row shelf/] }; 
	# to_field('location') now returns hashref of HTML::Elements for row and shelf.
	
	#class specific customizations of column_type can be useful
    sub column_type {
		my ($class, $col) = @_;
		# change default "No/Yes" options for this boolean field 
		return "BOOL('Off', 'ON')" if $col eq 'copy_protection'; 

		# Lie and get a cheap select box :) 
		return "ENUM('English', 'Spanish', 'German')" if $col eq 'language';
		
		return $class->SUPER::column_type($col);
	}
	...

	package Music::Rip;
	use base Music::DBI;
	use Music::CD;
	...

	__PACKAGE__->columns(qw/ripid format quality genre copy_protection hardcopy location language /);
	__PACKAGE__->is_a(ripid => Music::CD, 'cdid'); 
    sub column_type {
		# lock input to one value
		return "ENUM('NO')" if $col eq "harcopy";  

		# Take advantage of easy select box creation for any col
		return "ENUM('Best', 'Good', 'Bad')" if $col eq "harcopy";  

		# Let Class::DBI::Column::Type handle this one
		return undef if $col eq "format";          

		# Be efficient and go right to is_a class to get types for rest
		# Also handy if your base column_type method doesn't check is_a classes
		return Music::CD->column_type($col);
	}
	...

    # Now this call 
	my $cgi = Music::Rip->to_cgi;
	# RESULTS in these types of elements 
	# ripid 			=> text input 
	# format			=> text input
	# quality			=> select box with "Best" first and thus default 
	# genre 			=> select box with "Rock" first 
	# copy_protection	=> select box with "Off" and "On" having values 0 and 1 and
	#                      column definitions default value selected
	# hardcopy          => select box with one value, "No".
	# location          => { row => text input, shelf => text input } 
	# language          => select box "English" first 

    

--0-1316208330-1102668006=:36276
Content-Type: application/x-perl-module; name="AsForm.pm"
Content-Transfer-Encoding: base64
Content-Description: AsForm.pm
Content-Disposition: attachment; filename="AsForm.pm"

cGFja2FnZSBDbGFzczo6REJJOjpBc0Zvcm07CnVzZSA1LjAwNjsKdXNlIHN0
cmljdDsKdXNlIHdhcm5pbmdzOwp1c2UgQ2xhc3M6OkRCSTo6UGx1Z2luOjpU
eXBlICgpOyAjIEJ1ZyAgLS0gY29sdW1uX3R5cGUgcmV0dXJucyBjaGFyIGZv
ciBlbnVtIGNvbHMKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
IyBVc2UgY29sdW1uX3R5cGUgaW4gbW9kZWwgY2xhc3MgaW5zdGVhZCAKCnVz
ZSBEYXRhOjpEdW1wZXI7ICAjIHBqcyBmb3IgCnVzZSBDbGFzczo6REJJOjpt
eXNxbCAoKTsKb3VyICRPTERfU1RZTEUgPSAwOwoKdXNlIEhUTUw6OkVsZW1l
bnQ7CnJlcXVpcmUgRXhwb3J0ZXI7Cm91ciBASVNBID0gcXcoRXhwb3J0ZXIp
OwojIFBFVEVSIFNQRUxUWiAtLSAgQWRkZWQgbmV3ICJfdG9fKiIgbWV0aG9k
cyB0byBARVhQT1JUIApvdXIgQEVYUE9SVCA9IHF3KCB0b19jZ2kgdG9fZmll
bGQgX3RvX3RleHRhcmVhIF90b190ZXh0ZmllbGQgX3RvX3NlbGVjdAp0eXBl
X29mIF90b19mb3JlaWduX2lucHV0cyBfdG9fZW51bV9zZWxlY3QgX3RvX2Jv
b2xfc2VsZWN0ICk7IApvdXIgJFZFUlNJT04gPSAnMi4zJzsKCj1oZW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