[html-formfu] password element: empty after submission
Jens Schwarz
blacky6767 at gmx.de
Tue Nov 11 09:04:25 GMT 2008
Hi,
I am Catalyst/Perl/FormFu/TemplateToolkit-Newbie and have a problem *douh* ;)
I want to create a form where the user can change its password (i.e. something like "password" and "password confirm") and store it sha1-hashed in my mySQL-DB. In order to accomplish this, I thought I could get the contents of the password field after the user submission, run a sha1-hash over it an finally store it to the DB. But that does not work because after the user submits the password field it seems to be emtpy. Is this a FormFu problem?
Here is the situation right now:
<catalyst root>/root/src/foobar.tt2:
[% form %]
<catalyst root>/root/forms/foobar.yml:
---
indicator: submit
elements:
- type: Password
name: mypass
label: Enter password
constraints:
- type: Equal
others: mypass_confirm
- type: Required
- type: Password
name: mypass_confirm
label: Please confirm password
constraints:
- type: Required
- type: Submit
name: submit
value: Here we go
<catalyst root>/lib/MyApp/Controller/Root.pm:
sub foobar :Local :FormConfig('foobar.yml') {
my ($self, $c) = @_;
my $form = $c->stash->{form};
$c->log->info($form->get_element({ name => "mypass" }));
$c->stash->{template} = 'foobar.tt2';
}
<catalyst output after user has submitted form>:
[info] <div class="password label">
<label>Enter password</label>
<input name="mypass" type="password" value="" />
</div>
Please note the empty value attribute where I espected the user input!
If I now add a text field to my yml ...
<catalyst root>/root/forms/foobar.yml:
---
indicator: submit
elements:
- type: Text
name: mytext
constraints:
- type: Required
- type: Password
name: mypass
label: Enter password
constraints:
- type: Equal
others: mypass_confirm
- type: Required
- type: Password
name: mypass_confirm
label: Please confirm password
constraints:
- type: Required
- type: Submit
name: submit
value: Here we go
... and grab its contents ...
<catalyst root>/lib/MyApp/Controller/Root.pm:
sub foobar :Local :FormConfig('foobar.yml') {
my ($self, $c) = @_;
my $form = $c->stash->{form};
$c->log->info($form->get_element({ name => "mytext" }));
$c->stash->{template} = 'foobar.tt2';
}
... the output is as expected:
<catalyst output after user has submitted form>:
[info] <div class="text">
<input name="mytext" type="text" value="foo" />
</div>
The related versions are:
- Catalyst 5.7015
- Catalyst::Controller::HTML::FormFu 0.03004
- HTML::FormFu 0.03005
- Perl 5.10
Any hints on how I can get my password hashed as intended?
TIA
Jens
--
Psssst! Schon vom neuen GMX MultiMessenger gehört? Der kann`s mit allen: http://www.gmx.net/de/go/multimessenger
More information about the HTML-FormFu
mailing list