-
Notifications
You must be signed in to change notification settings - Fork 13
Rose::HTML::Objects
Rose::HTML::Objects is a framework for creating a resuable set of form and field widgets as mutable Perl objects that can be serialized to HTML or XHTML for display purposes. On the Perl side, these objects are treated as abstract entities that can be fed input and will produce output in the form that is most convenient for the programmer. (E.g., pass a DateTime object to a date picker field to initialize it, and get a DateTime object back from the field when asking for its value).
Fields may be simple (one standard HTML form field to one Perl field object) or compound (a field object that serializes to an arbitrary number of HTML tags, but can be addressed as a single logical field internally). Likewise, forms themselves can be nested.
Each field has its own customizable validation, input filter, output filter, internal value (a plain value or a Perl object, whatever is most convenient), output value (the value shown when the field is redisplayed), label, associated error, and any other metadata deemed necessary. Each field can also be serialized to the equivalent set of (X)HTML "hidden" fields. All HTML attributes are customizable.
All labels, errors, and messages used in the bundled form and field widgets are localized in several languages. An extensible localization framework is provided, allowing new languages to be added and new HTML widgets to have their own localized labels, errors, and messages.
Forms are expected to be initialized with, and return an object or list of objects that the form represents. For example, a registration form could be initialized with and return a UserAccount object.
Users are encouraged to create their own library of reusable form and field widgets for use on their site. A private library creation API is provided to make this as easy as possible. The expectation is that the same kind of field appears in multiple places in any large web application (e.g., username fields, password fields, address forms, etc.) Each field encapsulates a set of values (e.g., options in a pop-up menu), labels, validation constraints, filters, and error messages. Similarly, each form encapsulates a set of fields along with any inter-field validation, error messages, and init-with/object-from methods. Nesting forms and fields preserves this delegation of responsibility, with each higher level having access to its children to perform inter-form/field tasks.
A base set of field objects representing the standard HTML form tags as well as a several examples of compound and other custom fields are included in the distribution. There are also basic init-with/object-from methods for forms.
See the following POD for more information on the most prominent features:
- Rose::HTML::Objects
- Rose::HTML::Form::Field
- Rose::HTML::Form::Field::Compound
- Rose::HTML::Form
- Rose::HTML::Object::Message::Localizer
- Download
- Mailing list
- SVN repository
- IRC: irc.perl.org#rdbo