[Html-widget] trying to get the type of an element

Carl Franks fireartist at gmail.com
Wed Nov 15 14:54:52 GMT 2006


On 15/11/06, John Napiorkowski <jjn1056 at yahoo.com> wrote:
>
> --- Carl Franks <fireartist at gmail.com> wrote:
>
> > On 14/11/06, John Napiorkowski <jjn1056 at yahoo.com>
> > wrote:
> > > Okay,
> > >
> > > This is probably not the smartest question, but
> > I've
> > > looked at the source and the docs and I can't
> > figure
> > > out how to get the type of an element.  I just
> > can't
> > > say:
> > >
> > > $element->type;
> > >
> > > or any other combination I can think of.  There
> > must
> > > be a way to do this.  Anyone know?
> >
> > The only way to get that just now would be ref(
> > $element )
> > but that would give something like
> > 'HTML::Widget::Element::Textfield'
> >
> > You could use add a new method to H/W/Elements with
> > mk_accessors()
> > and then edit H/Widget::element() to store the type
> > it receives, using
> > that method after it's created the element.
> > Unfortunately, both Block and Button already have a
> > 'type' method, so
> > it'll need to be a different name - I can't really
> > think of anything
> > else that's suitable, as 'type' would be most
> > appropriate.
> >
> > Carl
>
> How about "form_tag" or "form_element" or
> "tag|element_name"?

Not anything with 'tag', as the element types don't map to HTML tag names:
I suggest 'element_type' so it's clear it's specific to HW.

Carl



More information about the Html-widget mailing list