On 12/13/05 6:28 AM, Sean Davis wrote: > how do you envision integrating a rose::db::object with a rose::html::object > (in particular, a form)? The correspondence between html::object and > db::object are almost 1:1, with the exception of relationships (that will show > up as option lists or something like that) to other tables. I could envision > making a module (don't know how yet) that would take the various datatypes > from RDBO and generate an HTML::Form object from it automatically. I guess > I'm just curious if you have examples of doing this kind of thing....
I'll have an actual CPAN module to do exactly what you describe eventually. But as you've surmised, it's pretty straightforward. To build the form, just iterate over the columns in an object and decide what kind of field you want for each column data type. The module I plan to release will likely show up on CPAN as Rose::DB::Object::Forms. It'll include three forms initially: a "create" form for making new objects, an "edit" form for editing existing objects, and a "search" form for gathering query parameters to pass to the Manager to find multiple objects. Here something to keep in mind when rolling your own solution in the interim. Remember that certain fields will likely be uneditable in an edit form, but editable in a create form. For example, the primary key may be a field in the create form but will be read-only data in an edit form. The same goes for auto-populated fields like "date_created DATETIME NOT NULL DEFAULT 'now'" or "last_modified TIMESTAMP". In these cases, the hidden_fields() method is your friend. Rather than printing the corresponding field for each column, remember that you can always print the hidden_fields() and get the same result. You can also opt not to print some of these fields at all, hidden or otherwise. Instead, just load() the object, update the object from the form, manually set the last_modified() value (for example), and then save(). (The primary key will have to be in a hidden field, however.) I'll also have a simple CRUD framework up under Rose::WebApp::CRUD eventually, and I'll probably "port" it to Catalyst as well. So much code, so little time... ;) -John ------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click _______________________________________________ Rose-db-object mailing list Rose-db-object@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rose-db-object