[Maypole] Access to has_a data from template?

From: Jesse Sheidlower (jester at panix.com)
Date: Thu Sep 16 2004 - 03:38:35 BST


I just sat down to do something I thought would be easy,
and found that I can't really figure out how to get it done.

I'd like to generate my own HTML form elements from within
a template, without using the built-ins that use as_form
or as_html. To pick the simplest example, suppose I'm in
my "book" class, at http://mysite.com/book/add . Each
"book" has_a "format".

I thought there would be a way to get right to the format
stuff, but there doesn't seem to be. Yet even when I start
with the Template::Plugin::Class stuff it doesn't seem to
work: if I try

  [% USE book = Class(classmetadata.name) %]

(classmetadata.name convieniently returns MyDB::Book or
whatever), I still can't seem to get at the related
stuff: doing something like

  FOREACH format = book.format

bombs out with

  undef error - Can't fetch data as class method at
  /usr/local/lib/perl5/site_perl/5.8.5/Template/Plugin/Class.pm
  line 35

I'd like ultimately to do something like

  [% CGI.popup_menu({ name => "format",
        values => ## SOMETHING
        labels => ## SOMETHING
        default => ## SOMETHING
   }) %]

Thanks. I'd think something like this should go into the
docs somewhere, for people who don't want to use the whole
HTML::Element autogeneration stuff.

Jesse Sheidlower

_______________________________________________
maypole mailing list
maypole at lists.netthink.co.uk
http://lists.netthink.co.uk/listinfo/maypole



This archive was generated by hypermail 2.1.3 : Thu Feb 24 2005 - 22:25:56 GMT