[html-formfu] Subclassing HTML::FormFu::Element::Select

Mario Minati mario.minati at googlemail.com
Sat Sep 22 17:33:55 GMT 2007


On Saturday 22 September 2007 17:19:22 Zbigniew Lukasiak wrote:
> Hi Carl,
>
> I've tried to subclass HTML::FormFu::Element::Select to experiment a
> bit with DBIC and FormFu integration, but I failed.  Here is what I
> done:
>
> The script:
>
> use HTML::FormFu;
>
> my $form = HTML::FormFu->new;
> $form->load_config_file('t/var/config.yml');
> warn $form->render;
>
> The config:
>
> ---
> elements:
>    - type: "Select::DBIC"
>      name: foo
>      options:
>        - [ 01, January ]
>        - [ 02, February ]
>        - value: 03
>          label: March
>          attributes:
>            style: highlighted
>        - [ 04, April ]
>
> When I change Select::DBIC to Select this config works.
>
> Then I have an empty Select::DBIC class:
>
> package HTML::FormFu::Element::Select::DBIC;
> use strict;
>
> BEGIN {
>     use vars qw($VERSION );
>     $VERSION     = '0.01';
> }
>
> use base 'HTML::FormFu::Element::Select';
>
> After some debugging I've added two more methods:
>
> sub render_class {
>     return 'HTML::FormFu::Render::Element::field';
> }
>
> sub render_class_args {
>     return {};
> }
>
> But it still fails with:
> Can't locate object method "submitted" via package
> "HTML::FormFu::Element::Select::DBIC" at
> /home/zby/svn/html-formfu/HTML-FormFu/lib//HTML/FormFu/Element/_Group.pm
> line 125.
>
> What do I wrong?

I don't see any obvious mistakes.

Did you try putting you module it in a custom lib directory like 
MyApp::HTML::FormFu::Element::Select::DBIC
an use as Type in you yml "type: +MyApp::HTML::FormFu::Element::Select::DBIC"?

On the other side make an empty subclass:

package HTML::FormFu::Element::Select::DBIC;
use strict;
use base 'HTML::FormFu::Element::Select';

That definite should work and than extend it one by one.

Greets,
Mario




More information about the HTML-FormFu mailing list