[Catalyst] Trouble using Catalyst::Controller::FormBuilder

Eric Berg eberg at bergbrains.com
Wed Nov 10 14:35:52 GMT 2010


Ok.  Thanks Hernan and Dave.  I've been using FormBuilder for years, but =

will take a look at FormHandler.

Eric

On 11/10/10 9:25 AM, Hernan Lopes wrote:
> indeed, again:
>
> here is a simple form example of formhandler with perl catalyst:
>
> in your User.pm controller:
>
> use HTML::FormHandler;
>
> sub fields {
>    return [
>        display0 =3D> {
>            type =3D> 'Display',
>            html =3D> '<h1>Personal data</h1>',
>            },
>        name =3D> {
>            type             =3D> 'Text',
>            label            =3D> 'Name',
>            required         =3D> 0,
>            required_message =3D> 'required',
>            css_class        =3D> 'form50',
>        },
>        submit =3D> {
>            type      =3D> 'Submit',
>            css_class =3D> 'form100 clear',
>            value     =3D> 'submit',
>        },
>    ];
> }
>
>
> sub myform :Path('/myform') :Args(0) {
>    my ( $self, $c ) =3D @_;
>    my $form =3D
>    HTML::FormHandler->new(
>    field_list =3D> $self->fields);
>   $c->res->body( $form->render );
> }
>
>
> And, start your server,  access your http://localhost:3000/myform
>
> see more on the catalyst manual and formhandler manual
>
>
> -Hernan
>
>
>
> On Wed, Nov 10, 2010 at 12:11 PM, David Schmidt <davewood at gmx.at =

> <mailto:davewood at gmx.at>> wrote:
>
>     On Wed, Nov 10, 2010 at 2:37 PM, Eric Berg <eberg at bergbrains.com
>     <mailto:eberg at bergbrains.com>> wrote:
>     > I'm trying to get Catalyst::Controller::FormBuilder to work, but
>     am running
>     > into some problems.  Per the docs, the config should be like this:
>     >
>     > use base 'Catalyst::Controller::FormBuilder';
>     >
>     > But my class is from a brand-new Catalyst install, so it's using
>     extends
>     > like this:
>     >
>     > BEGIN {extends 'Catalyst::Controller'; }
>     >
>     >
>     > So I changed it to this:
>     >
>     > BEGIN {extends 'Catalyst::Controller::FormBuilder'; }
>     >
>     > And now I'm seeing this error:
>     >
>     > Couldn't load class (GLR) because: Couldn't instantiate component
>     > "GLR::Controller::Payment", "The 'add_attribute' method cannot
>     be called on
>     > an immutable instance at
>     > /usr/local/lib/perl/5.10.1/Class/MOP/Class/Immutable/Trait.pm
>     line 32
>     >
>     >
>     > Can anyone steer me in the right direction to get this working?
>      BTW, I'm a
>     > long-time Perl guy, but this is my first Catalyst app.
>     >
>     > Thanks!
>     >
>     > Eric
>     >
>     >
>     > _______________________________________________
>
>
>     People seem to move towards HTML::FormHandler these days.
>     http://search.cpan.org/~gshank/HTML-FormHandler-0.32005/
>     <http://search.cpan.org/%7Egshank/HTML-FormHandler-0.32005/>
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20101110/fd6fd=
57b/attachment.htm


More information about the Catalyst mailing list