[Dbix-class] DBIX::Class - CGI::FormBuilder select-options problem

Carl Franks fireartist at gmail.com
Tue Dec 12 13:28:05 GMT 2006


On 12/12/06, Igor Longagnani <i.longagnani at synervis.it> wrote:
> Hi,
> i am a newbie with DBIx::Class and Catalyst so i beg your pardon in
> advance for my question:
>
> I do use with success DBIx::Class in other situations (easy ones) and
> I am trying to populate the option fields of a "select tag" named
> "soggetto" described through CGI::Formbuilder
> with data selected from an Oracle DB via DBIx::Class/Catalyst webapp
> runinng on catalyst developement server on port 3000.
> This is what doesn't work, i mean syntax is correct but output not what
> i excpected:
>
> Inside a Catalyst Controller class:
>
> my @data = $c->model('myDB::AnaEsercenti')->search(undef,{select =>
> [qw/userid name/]})->all();
> $c->form->options({ soggetto  => \@data});

You need to pass options() an arrayref of arrayrefs - you're passing
an arrayref of objects.

Something like this:

my @data = map { [ $_->userid, $_->name ] }
	$c->model('myDB::AnaEsercenti')
	->search(undef,{select => [qw/userid name/]})
	->all();

$c->form->options({ soggetto  => \@data});



More information about the Dbix-class mailing list