[html-formfu] Bug bug bu g bug

Ruben Fonseca rubenfonseca at di.uminho.pt
Fri Oct 26 11:05:34 GMT 2007


Hi! I was following the Cookbook on the section "Custom error messages"
but the hack does not work for me. I'm using all the latest CPAN
releases. Here is the small steps to reproduce the problem. I've tried
on both Linux and MacOS with the same problem.

Steps to reproduce:

$ catalyst.pl foo
$ cd foo
$ ./script/foo_create.pl view TT TT
$ ./script/foo_create.pl HTML::FormFu
$ ./script/foo_create.pl controller foo
$ vim lib/foo/Controller/foo.pm

use base 'Catalyst::Controller::HTML::FormFu';

sub bar : Local : FormConfig {
    my ($self, $c) = @_;

    my $form = $c->stash->{form};

$form->get_field('test')->get_constraint('Callback')->force_errors(1);

    $form->process($c->req->params);
}

$ mkdir -p root/forms/foo/
$ vim root/forms/foo/bar.yml

---
elements:
  - type: Text
    name: test
    constraints:
      - type: Callback
        message: lorem ipsum

$ mkdir -p root/foo
$ vim root/foo/bar.tt

[% form %]

$ ./script/foo_server.pl
A call to http://localhost:3000/foo/bar results in:

Caught exception in foo::Controller::foo->bar "Can't call method
"force_errors" on an undefined value
at /home/krani1/tmp/foo/script/../lib/foo/Controller/foo.pm line 11."

I've tried to get the element and create a new constraint on runtime.
Altought this results in no error, it does not make my form appear with
an error. Any hint?

Cheers
Rúben

---------------------------------------------------------
Rúben Fonseca <ruben.fonseca at log.pt>
Technical Consultant
log <www.log.pt>

Tel: +351 21 330 42 20
Fax: +351 21 330 42 19
Calçada Marquês de Abrantes, 45 - 3º Dto
1200-718 Lisboa
---------------------------------------------------------




More information about the HTML-FormFu mailing list