in reply to Trying to pass a hash ref to a module

my $page = $form->fill(scalarref => \$html, fobject => $info);

Change 'fobject' to 'fdat'. The 'fobject' parameter expects an object ref. 'fdat' will accept a hashref or apparently an arrayref too (according to the docs).


Dave

Replies are listed 'Best First'.
Re^2: Trying to pass a hash ref to a module
by bradcathey (Prior) on May 17, 2005 at 21:23 UTC

    davido, thanks for the lead I miss not be getting the hash right. How does one have a hash with lots of values that have the same key, other than using an Array of Hashes?

    Anyway, I tried this--no error, but nothing got populated on the form.

    my $q = new CGI; my @info = { 'address' => '123 Main', 'choices' => '2' }; my $template = HTML::Template->new( filename => "../form.tmpl"); my $html = $template->output; my $form = new HTML::FillInForm; my $page = $form->fill(scalarref => \$html, fdat => \@info); print "Content-type: text/html\n\n"; print $page;

    Ideas?


    —Brad
    "The important work of moving the world forward does not wait to be done by perfect men." George Eliot
      Change @info and \@info to simply $info.

      my $info = { address => '123 Main', choices => '2' };
      and
      my $page = $form->fill(scalarref => \$html, fdat => $info);

      The docs for HTML::FillInForm states 'To pass multiple values using %fdat use an array reference'. At first read, this might lead you to think that you could pass an array reference instead of a hash reference, but what they actually mean is to use an array reference within the hash reference to specify multiple values for a given key.

      my $info = { address => '123 Main', choices => [ '2', '3', '4' ] };

        Thanks djohnston, that was it! I had tried several more options, but that combination worked.


        —Brad
        "The important work of moving the world forward does not wait to be done by perfect men." George Eliot