[dancer-users] Trapping parameters from a dynamic list of checkboxes.

WK wanradt at gmail.com
Thu Aug 27 16:07:30 BST 2015


2015-08-27 17:28 GMT+03:00 Richard Reina <gatorreina at gmail.com>:

> After figuring out how to accommodate my placeholder in selectall_hashref I
> did this:
>
>  my $Accomps = $dbh->selectall_hashref( $q, 'ID', \%attr, $Sid );

If you need placeholder here, but you don't have need for any
attributes, you may use `undef` here

my $Accomps = $dbh->selectall_hashref( $q, 'ID', undef, $Sid );

> Then as you suggested I do:
>
>  # get parameter for accomp type keys
>       foreach my $key ( keys %$Accomps ) {
>       print "Checking: " . $key . " for value.\n";
>       if ( param( $key ) ) {
>           $input_hash->{ $key } = $Accomps->{ $key };
>           print $key $input_hash->{ $key } . "\n";
>       }
>       }
>
> (just printing temporarily to see if it trapped the values)

Here we actually don't need values of $Accomps-hashref, we just using
it as list to check out form values, so depending of your futher
needs, you may assign your specific value here, like, for example:

           $input_hash->{ $key } = 1;

> However, I get this error:
>
>  Route exception: Can't use string ("1") as a symbol ref while "strict refs"
> in use at /home/richard/Dancer2/MyApp/bin/../lib/MyApp.pm line 557.
>
> Any idea what I am doing wrong?

What is on line 577 of your MyApp.pm?

Wbr,
-- 
Kõike hääd,

Gunnar


More information about the dancer-users mailing list