To expand on one each form is itself a file component. I am staunchly against javascript and I could accomplish the same thing essentially because each form is unique with a name=<% $m->current_comp->name %>
Code speaks a thousand words, let me show you the solution the I came up with to add closure to this problem, btw I did add a hidden form field.
<%attr>
http_title =>'Admin Widget'
widget_title =>'Change Password'
</%attr>
<div class="window">
<div class="title">
<% $title %>
</div>
<div class="body">
<form method="post" action="<% $m->caller(0)->name %>">
<table style="width:100%">
<tr>
<td style="width:50%">
New Password: <input type="password" name="password" size
+="30" />
</td>
<td>
Confirm Password: <input type="password" name="password_c
+onfirm" size="30" />
</td>
</tr>
<tr>
<td colspan="2">
<input type="hidden" name="form" value="<% $m->current_com
+p->name %>" />
<input type="submit" value="Change my Password" />
</td>
</tr>
</table>
</form>
</div>
</div>
<%init>
if ( $form eq $m->current_comp->name )
{
if ( defined $password && defined $password_confirm )
{
if ( $password eq $password_confirm )
{
$dbh->do( qq{UPDATE users SET "password" = ? WHERE "pkid" = ?
+}, {}, sha1_base64($password), $S->{'pkid'} );
$title .= " || You have changed your password.", print $S->{pk
+id};
}
else
{
$title .= " || Passwords do not match.";
}
}
else
{
$title .= " || Not enough information.";
}
}
</%init>
<%shared>
use Digest::SHA1 q/sha1_base64/;
my $title = $m->current_comp->attr('widget_title');
</%shared>
<%args>
$S
$password_confirm => $m->caller_args(1)->{'password'} || undef
$password => $m->caller_args(1)->{'password_confirm'} || u
+ndef
$form => $m->caller_args(1)->{'form'} || undef
</%args>
This is just a sample, and I plan on writing a serious mason tutorial on alot of the concepts I employ in the frameworks I have made.
$S is the session data sent from the autohandler.
the other caller ($password_confirm, $password, $form) args come from what ever serves as the console.
<% $m->caller(0)->name %>allows me to dynamically target the component for posting (though this works with limited success)
Take notice to
if ( $form eq $m->current_comp->name ) dynamic again.
I still need to fix it up but have a deadline of monday so I'll play with it later.
Evan Carroll
www.EvanCarroll.com
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.