CGI-Application-Plugin-FormState
view release on metacpan or search on metacpan
as:
$self->redirect($self->link('/app.cgi', 'rm' => 'list', 'cap_form_state' => $self->form_state->id));
Or, in the case of a link to the currently running app:
$self->redirect($self->self_link('rm' => 'list', 'cap_form_state' => $self->form_state->id));
IMPLEMENTATION
When you call "$self->form_state" for the first time, a top-level key is
created in the user's session. This key contains a random, hard-to-guess
element. It might look something like:
form_state_cap_form_state_84eb13cfed01764d9c401219faa56d53
All data you place in the form state with "param" is stored in the
user's session under this key.
You pass the name of this key on to the next instance of your
application by means of a hidden field in your form:
<input type="hidden" name="cap_form_state" value="<tmpl_var cap_form_state>">
You manually put this hidden field in your template. The template
parameter "cap_form_state" is automatically added to your template
parameters via the "load_tmpl" hook. It contains the random,
hard-to-guess portion (e.g. "84eb13cfed01764d9c401219faa56d53"). When
the template is filled, the hidden field will look something like this:
<input type="hidden" name="cap_form_state" value="84eb13cfed01764d9c401219faa56d53">
Since all values are stored on the server in the user's session, the
user can't tamper with any of them.
To keep old form_data from cluttering up the user's session, the system
uses CGI::Session's "expire" feature to expire old form state keys after
a reasonable amount of time has passed (2 days by default).
clear_params
Clear all of the values in the form state storage:
$self->form_state->param('name' => 'Road Runner');
$self->form_state->clear_params;
print $self->form_state->param('name'); # undef
delete
Deletes the form_state storage from the user's session.
id Returns the current value of the storage param - the "hard to guess"
portion of the session key.
my $id = $self->form_state->id;
name
Returns the current name being used for storage. Defaults to
"cap_form_state".
my $name = $self->form_state->name;
lib/CGI/Application/Plugin/FormState.pm view on Meta::CPAN
Or, in the case of a link to the currently running app:
$self->redirect($self->self_link('rm' => 'list', 'cap_form_state' => $self->form_state->id));
=head1 IMPLEMENTATION
When you call C<< $self->form_state >> for the first time, a top-level
key is created in the user's session. This key contains a random,
hard-to-guess element. It might look something like:
form_state_cap_form_state_84eb13cfed01764d9c401219faa56d53
All data you place in the form state with C<param> is stored in the
user's session under this key.
You pass the name of this key on to the next instance of your
application by means of a hidden field in your form:
<input type="hidden" name="cap_form_state" value="<tmpl_var cap_form_state>">
You manually put this hidden field in your template. The template
parameter C<cap_form_state> is automatically added to your template
parameters via the C<load_tmpl> hook. It contains the random,
hard-to-guess portion (e.g. C<84eb13cfed01764d9c401219faa56d53>). When
the template is filled, the hidden field will look something like this:
<input type="hidden" name="cap_form_state" value="84eb13cfed01764d9c401219faa56d53">
Since all values are stored on the server in the user's session, the
user can't tamper with any of them.
To keep old form_data from cluttering up the user's session, the system
uses L<CGI::Session>'s C<expire> feature to expire old form state keys
after a reasonable amount of time has passed (2 days by default).
lib/CGI/Application/Plugin/FormState.pm view on Meta::CPAN
# if we do, we'll delete all params in the user's session!
if ($self->{'__STORAGE_KEY'}) {
$self->{__CGIAPP_OBJ}->session->clear($self->{'__STORAGE_KEY'});
}
}
=item id
Returns the current value of the storage param - the "hard to guess"
portion of the session key.
my $id = $self->form_state->id;
=cut
sub id {
my $self = shift;
if (!$self->{'__CONFIGURED'}) {
( run in 3.202 seconds using v1.01-cache-2.11-cpan-748bfb374f4 )