[Html-widget] Re: FormFu custom element with javascript

Carl Franks fireartist at gmail.com
Thu Mar 15 10:35:47 GMT 2007


On 14/03/07, Mario Minati <mario.minati at googlemail.com> wrote:
> Am Dienstag 13 März 2007 23:45 schrieben Sie:
> > As I understand the code, the place to generate a custom javascript for the
> > widget is in a custom render function, right?

All field elements have a javascript() method.
Look in file "root/field" to see where it's used.

We probably ought to have a javascript() method on form, too.
Maybe add a new issue for this on the project page?
http://code.google.com/p/html-formfu/issues/list

> > My problem is now that I need the id of the widget to access it later via
> > javascript, but prepare_id has not been called yet in the render function
> > of Element.pm.
> >
> > Is it possible to call prepare_id before creating the render object or
> > would that mix something up?

Now that we don't have the intermediate $result object, this is harder.
prepare_id() has to do it's work on the $render object, so that it
doesn't change the original form/field at all - which would cause
problems, if for example, you cloned the form and gave the new form a
different ID. The field would have a hard-coded ID, so auto_id()
wouldn't be used.

> Ok I found out that changing the position is not possible.
>
> How to fix this?
> Is there a way to tell TT to double parse the content? This way we could use
> TT stuff inside the render function e.g. "[self.id]" to access the id.

My first thought is that if you're needing access to the ID during
form creation, you probably ought to be setting that field's ID
explicitly.

Carl



More information about the Html-widget mailing list