[html-formfu] Subclassing HTML::FormFu::Element::Select
Zbigniew Lukasiak
zzbbyy at gmail.com
Mon Sep 24 10:33:20 GMT 2007
After I changed the name to MySelect (without a :: in the name) it worked.
Hey Carl - are you listening?
By the way - do you guys use irc?
--
Zbyszek
On 9/22/07, Mario Minati <mario.minati at googlemail.com> wrote:
> 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
>
>
> _______________________________________________
> HTML-FormFu mailing list
> HTML-FormFu at lists.scsys.co.uk
> http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu
>
--
Zbigniew Lukasiak
http://brudnopis.blogspot.com/
More information about the HTML-FormFu
mailing list