[prev] [thread] [next] [Date index for 2004/12/03]
I'm working with IsA and AsForm. I noticed in AsForm, for cols inherited by
isa, the column type is not obtained. This makes every input be a simple text
type.
I overrode column_type in my model class and call it from AsForm rather than
the one it usually calls. It uses a sub which to get types of is_a inherited
cols. A couple questions:
1) Will $class->__isa_rels{$column} ever return an array with more than one
value?
2) When you make a is_a rel, it automatically make a column_type method that
works?
Here's my code I have in my base model class.
# determine column type of a is_a inherited field if it can.
sub _maybe_isa_col_type {
my $class = shift;
my $col = shift or die "Need a column for _maybe_isa_col_type";
my $type;
eval {
my $isa_rels = $class->__isa_rels;
# get first type we come to for column in a isa class
foreach ($class->columns) {
my $isa_class = $isa_rels->{$_}->[0]; # will this ever have
more one?
# I hope not.
if ($isa_class) {
$type = $isa_class->column_type($col);
warn "isa class = $isa_class col = $col type = $type";
}
last if $type;
}
};
return $type;
}
sub column_type {
my $class = shift;
my $col = shift or die "Need a column for column_type";
my $type = $class->_column_info->{$col}->{type} ||
$class->_maybe_isa_col_type($col);
}
thanks,
=====
pjs
__________________________________
Do you Yahoo!?
Yahoo! Mail - 250MB free storage. Do more. Manage less.
http://info.mail.yahoo.com/mail_250
|
IsA and AsForm
|
Generated at 12:00 on 04 Dec 2004 by mariachi v0.52