CC: | palvelinkeskus [...] plenware.fi |
Subject: | Class::DBI::AsForm, _to_select and null values |
Date: | Wed, 12 Jul 2006 20:26:03 +0300 |
To: | bug-Class-DBI-AsForm [...] rt.cpan.org |
From: | Jaska Kivelä <jaska.kivela [...] plenware.fi> |
Hello.
We're using Class::DBI::AsForm to generate forms for a small application.
There is a problem with 'non-Essential' fields and 'has-a' relationships:
we would need a SELECT block with a null OPTION.
Here's a diff (against 2.42), that does the trick:
--clip--
*** AsForm.pm.orig 2006-07-12 20:19:29.000000000 +0300
--- AsForm.pm 2006-07-12 20:25:23.000000000 +0300
***************
*** 125,130 ****
--- 125,133 ----
my $has_a_class = $hint || $self->__hasa_rels->{$col}->[0];
my @objs = $has_a_class->retrieve_all;
my $a = HTML::Element->new("select", name => $col);
+ unless(grep {$_ eq $col} $self->_essential()) {
+ $a->push_content( new HTML::Element('option', value => '') );
+ }
for (@objs) {
my $sel = HTML::Element->new("option", value => $_->id);
$sel->attr("selected" => "selected")
--clap--
--
Jaska Kivelä | Plenware Group Oy | gsm 040 576 2988
jaska.kivela@plenware.fi | Patamäenkatu 7 | fax 010 665 3060
asiantuntija | PL 13, 33201 TAMPERE |
Message body not shown because it is not plain text.