Forum OpenACS Development: How to store formbuilder attributes

Collapse
Posted by Malte Sussdorff on
Taking this to the next level. If I want to create an cr_item that uses the form builder to display itself, how would you store the additional attributes that should be passed along to the formbuilder?

For sure, there is an attribute "formbuilder_widget" which defines which widget to use (e.g. textarea or matrix). But how do I store the additional attributes, as they are different for each type of widget. I thought of using an attribute "widget_attributes_xml" that stores the additional attributes in an XML scheme.

Alternatively, and now I'm blurting things out without really double checking it works, we could use xoTCL to handle the display of things using (multiple) inheritance. Here is how I envision it, not sure as mentioned before, if it would work at all.

We create a question "How old are you?". A new as_item_type object is created. We define it should be a text input box. Immediately the widget_type attribute would be set to "text input box" and the object would inherit more attributes from the "text input box" class, which we can set at a later stage (like "size" or "show while typing"). We then define that we also want to have a validity check of type "integer_range". The object would inherit attributes from this class like "low_end" and "high_end". We might want to have multiple types of checks associated, so we inherit more attributes from other types. To get this persistent, we would store it in XML format in the DB.

When displaying, we would call specific functions for each type (e.g. a display function for the "text input box" that returns the XHTML code, based on the attributes).

My question: Is it worthwhile to continue thinking down these lines or how would you solve the problem of dynamic attributes depending on some choices made in the creation of the question. Not to mention the possibility to change the display type or certain checks of a question at a later stage (which results in a different set of attributes associated with the question, e.g. if we decide to switch to multiple choice radio box with the age ranges instead).

Again, please accept my apologies if this is utter glibberish to you.