Peter Karman > Rose-HTMLx-Form-Related-0.22 > Rose::HTMLx::Form::Related



Annotate this POD


Open  0
View/Report Bugs
Module Version: 0.22   Source   Latest Release: Rose-HTMLx-Form-Related-0.24


Rose::HTMLx::Form::Related - RHTMLO forms, living together


 package MyForm;
 use strict;
 use parent 'Rose::HTMLx::Form::Related';


Rose::HTMLx::Form::Related is a subclass of Rose::HTML::Form. Rose::HTMLx::Form::Related can interrogate the relationships between ORM classes and the Forms that represent them, and use that data to tie multiple Rose::HTMLx::Form::Related classes together.

There are some additional convenience methods provided, as well as the addition to two more field types (boolean and autocomplete) not part of the standard Rose::HTML::Form installation.



Overrides base method to call interrelate_fields() if metadata->interrelate_fields() is true.


Creates and returns a Rose::HTMLx::Form::Related::Metadata object. This method will not be called if a metadata object is passed in new().


Returns name of the metadata class. Default is 'Rose::HTMLx::Form::Related::Metadata'.


Returns name of class whose instances are stored in app().

Default is the emptry string.


Returns 0 by default, unless the RHTMLO_DEBUG env var is set to a true value.


Shortcut to metadata->object_class.

hidden_to_text_field( hidden_field_object )

Returns a Text field based on hidden_field_object.


Returns array ref of field names sorted numerically by their rank attribute.

interrelate_fields( [ N ] )

Called by init() after the SUPER::init() method has been called if the metadata->interrelate_fields boolean is true (the default).

interrelate_fields() will convert fields that return true from metadata->related_field() to menu or autocomplete type fields based on foreign key metadata from metadata->object_class().

In other words, interrelate_fields() will convert your many-to-one foreign-key relationships into HTML fields that help enforce the relationship.

The N argument is the maximum number of values to consider before creating an autocomplete field instead of a menu field. The default is 50, which is a reasonable number of options in a HTML menu.

get_objects_count( object_class => class_name )

Returns an integer reflecting the number of objects available for iterrelate_fields().

The default is 100 which is useless. You should override this method in your subclass to actually query the db. All counts are memoized internally so get_objects_count() will only ever be called once per class_name.

get_objects( object_class => foreign_class_name )

Returns an array ref of objects of type foreign_class_name. The array ref is used by interrelate_fields() to auto-populate popup menus.

The default is to return an empty array ref. Override in your subclass to do something more meaningful.

Note that get_objects() will be called by clear() and reset() so that you can cache Form objects and always get up-to-date menu options.


Overrides base method to always return the Form object that called the method.


Overrides base method to reset any options in any interrelated menu fields by calling get_objects() again.


Overrides base method to reset any options in any interrelated menu fields by calling get_objects() again.


Peter Karman, <karman at>


Please report any bugs or feature requests to bug-rose-htmlx-form-related at, or through the web interface at I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.


You can find documentation for this module with the perldoc command.

    perldoc Rose::HTMLx::Form::Related

You can also look for information at:


The Minnesota Supercomputing Institute sponsored the development of this software.


Copyright 2008 by the Regents of the University of Minnesota.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

syntax highlighting: