[Bast-commits] r3365 - trunk/DBIx-Class-WebForm/lib/DBIx/Class
castaway at dev.catalyst.perl.org
castaway at dev.catalyst.perl.org
Tue May 22 17:32:04 GMT 2007
Author: castaway
Date: 2007-05-22 17:32:03 +0100 (Tue, 22 May 2007)
New Revision: 3365
Modified:
trunk/DBIx-Class-WebForm/lib/DBIx/Class/WebForm.pm
Log:
Stuff I did a looong time ago..
Modified: trunk/DBIx-Class-WebForm/lib/DBIx/Class/WebForm.pm
===================================================================
--- trunk/DBIx-Class-WebForm/lib/DBIx/Class/WebForm.pm 2007-05-22 16:24:15 UTC (rev 3364)
+++ trunk/DBIx-Class-WebForm/lib/DBIx/Class/WebForm.pm 2007-05-22 16:32:03 UTC (rev 3365)
@@ -33,7 +33,7 @@
sub create_from_form {
my $class = shift;
- die "create_from_form can only be called as a class method" if ref $class;
+# die "create_from_form can only be called as a class method" if ref $class;
__PACKAGE__->_run_create( $class, @_ );
}
@@ -43,7 +43,7 @@
sub update_from_form {
my $self = shift;
- die "update_from_form cannot be called as a class method" unless ref $self;
+# die "update_from_form cannot be called as a class method" unless ref $self;
__PACKAGE__->_run_update( $self, @_ );
}
@@ -89,17 +89,18 @@
=cut
sub to_field {
- my ( $self, $field, $how ) = @_;
+ my ( $self, $field, $how, $value ) = @_;
+ print STDERR "Foo $field\n";
my $class = ref $self || $self;
if ( $how and $how =~ /^(text(area|field)|select)$/ ) {
no strict 'refs';
my $meth = "_to_$how";
return $class->$meth($field);
}
-# print STDERR "Foo\n";
-# print STDERR $self, "\n";
+# print STDERR ref $self, "\n";
my $hasa = $self->relationship_info($field);
+# print STDERR keys (%{$self->relationships});
# print STDERR $hasa, "\n";
my $rs;
if(!ref($self))
@@ -125,14 +126,14 @@
# print STDERR "NOT\n";
- return $self->_to_textfield($field) unless($self->has_column($field));
+ return $self->_to_textfield($field, $value) unless($self->has_column($field));
my $type = $class->column_type($field);
-# print STDERR $type, $class->column_info($field)->{size}, "\n";
+# print STDERR "TYPE, ", $type, $class->column_info($field)->{size}, "\n";
return $self->_to_textarea($field)
if $type
and $type =~ /^(TEXT|BLOB)$/i
or (uc $type eq 'VARCHAR' and $class->column_info($field)->{size} > 80);
- return $self->_to_textfield($field);
+ return $self->_to_textfield($field, $value);
}
sub _to_textarea {
@@ -148,10 +149,12 @@
}
sub _to_textfield {
- my ( $self, $col ) = @_;
- my $value = ref $self && $self->$col;
+ my ( $self, $col, $defval ) = @_;
+ my $value = ref $self && $self->can($col) && $self->$col;
+ $value ||= $defval;
my $a = HTML::Element->new( "input", type => "text", name => $col );
$a->attr( "value" => $value ) if $value;
+# print STDERR "_to_textfield $a";
$a;
}
More information about the Bast-commits
mailing list