This is just colorized HTML to illustrate the explanation in the wiki.
Three ways we can send arguments to a Mojolicious action -
<form method="post" action="/form/reservation?arrival=friday&departure=sunday"> <input name="room" value="42" type="text"> <input name="surname" value="Adams" type="text"> <input type="radio" name="breakfast" value="toast">toast <input type="radio" name="breakfast" value="eggs">eggs <input type="checkbox" name="season" value="summer">summer <input type="checkbox" name="season" value="winter">winter <input type="checkbox" name="season" value="autumn">autumn <input type="checkbox" name="season" value="spring">spring <input type="submit"> </form>
And here's how we can access them from the mojolicious controller, within code that looks like this:
post '/form/:test' => sub { my $self = shift; . . . $self->render(...); };
$self is a mojolicious controller. In each case, we call $obj->param
for a
list of names, $obj->param("arg")
for the value
(or list of values):
$self->param
params from route, post and get
PARAM | VALUE |
---|---|
arrival | friday |
breakfast | eggs |
departure | sunday |
room | 42 |
season | summer |
surname | Addams |
test | reservation |
$self->req->param
params from post and get
PARAM | VALUE |
---|---|
arrival | friday |
breakfast | eggs |
departure | sunday |
room | 42 |
season | summer |
surname | Addams |
$self->req->query_params
params from get
PARAM | VALUE |
---|---|
arrival | friday |
departure | sunday |
$self->req->body_params
params from post
PARAM | VALUE |
---|---|
breakfast | eggs |
room | 42 |
season | summer |
surname | Addams |