Search code examples
perlparametersmojolicious

Mojolicious every_param not populating array for integers


  my $warranty_dates  = $self->every_param('warranty_date');
  my $state_ids       = $self->every_param('state_id');

results in:

   $VAR1 = undef;

and

  $VAR1 = '12/12/2017';
  $VAR2 = '12/12/2017';
  $VAR3 = '12/12/2017';
  $VAR4 = '12/12/2017';
  $VAR5 = '12/12/2017';

respectively when called by

  die Dumper(@{$state_ids});

  die Dumper(@{$warranty_dates});

despite being shown as having the following parameters:

  "state_id" => [
    1,
    1,
    1,
    1,
    1
   ],
  "warranty_date" => [
    "12/12/2017",
    "12/12/2017",
    "12/12/2017",
    "12/12/2017",
    "12/12/2017"

Solution

  • So I've found the answer, which is that I didn't address the parameters as post requests.

    https://corky.net/dotan/programming/mojolicious-request-parameters-example.html

    quick explanation of why some of these parameters need to be in the format

    $self->req->every_param('');
    

    Passing arguments to redirect_to in mojolicious and using them in the target controller