[Maypole] Pop-up menus from related tables?

Jesse Sheidlower jester@panix.com
Mon, 15 Mar 2004 21:57:20 -0500


This is probably because I don't grok the AsForm stuff, but I
am having trouble getting values from a related table appear
in a pop-up menu, which I thought was automatic.

As part of an app, I have two tables:

 CREATE TABLE `image` (
  `id` int(10) unsigned NOT NULL auto_increment,
  `biblio` int(10) unsigned NOT NULL default '0',
  `image` blob NOT NULL,
  `mime_type` varchar(30) NOT NULL default '',
  `category` int(10) unsigned NOT NULL default '0',
  PRIMARY KEY  (`id`)
)

 CREATE TABLE `category` (
  `id` int(10) unsigned NOT NULL auto_increment,
  `category` varchar(255) default NULL,
  PRIMARY KEY  (`id`)
) 

The "category" column in the "image" table holds the PK of the
row in the "category" table. (The "biblio" is the PK of the
row in the "biblio" table that the image represents.)

My Database::Image module has:

  Database::Image->has_a(category => "Database::Category");

Right now, when I go to the edit or add pages for the Image
table, the "category" column appears as a textfield. Similarly, 
any display page just shows the integer. What's the proper
setup I should be using? And, if I'm using my own template and
want to get a specific format, how do I (a) get a desired
HTML element (popup menu, scrolling list, checkbox group)
populated from the related table, and (b) get the right 
output, from the lookup table?

Thanks. I don't actually have upload working, I'm just 
trying to get the display right for this and some similar
applications.

Jesse Sheidlower