Forum OpenACS Development: Object Management

Collapse
Posted by Dave Bauer on
I am using acs-object-management to great effect.

I have a few suggestions and a question or two.

First I have added "Label" and HTML class as widget parameters. This makes it very easy to customize a form.

I am wondering how to set hidden variables. For example I need to add a "parent_id" for an object and I want to set it as a hidden form field.

I suppose I can add a hidden widget additionally. Is this the best option?

Thanks
Dave

Collapse
2: Re: Object Management (response to 1)
Posted by Ryan Gallimore on
Hi Dave,

I added the following for hidden fields (and a few more fields and parameters) that was very useful in acs-object-management.

Index: acs-templating-changes-create.sql
===================================================================
RCS file: /cvsroot/openacs-4/packages/acs-object-management/sql/postgresql/acs-templating-changes-create.sql,v
retrieving revision 1.4
diff -u -r1.4 acs-templating-changes-create.sql
--- acs-templating-changes-create.sql 2 Jan 2010 14:03:59 -0000 1.4
+++ acs-templating-changes-create.sql 10 Jan 2013 14:18:41 -0000
@@ -248,6 +248,16 @@
values
(93, 'timestamp', 'year_interval', 'f', 'f', 'f', null);

+ insert into acs_form_widget_params
+ (param_id, widget, param, required_p, html_p, tcl_allowed_p, default_value)
+ values
+ (94, 'timestamp', 'before_html', 'f', 'f', 't', null);
+
+ insert into acs_form_widget_params
+ (param_id, widget, param, required_p, html_p, tcl_allowed_p, default_value)
+ values
+ (95, 'timestamp', 'after_html', 'f', 'f', 't', null);
+
-- date widget
insert into acs_form_widgets (widget) values ('date');

@@ -266,6 +276,16 @@
values
(111, 'date', 'value', 'f', 'f', 't', null);

+ insert into acs_form_widget_params
+ (param_id, widget, param, required_p, html_p, tcl_allowed_p, default_value)
+ values
+ (112, 'date', 'before_html', 'f', 'f', 't', null);
+
+ insert into acs_form_widget_params
+ (param_id, widget, param, required_p, html_p, tcl_allowed_p, default_value)
+ values
+ (113, 'date', 'after_html', 'f', 'f', 't', null);
+
-- richtext widget
insert into acs_form_widgets (widget) values ('richtext');

@@ -689,4 +709,63 @@
values
('string','search');

+ /* TODO Hidden widget - Add to HEAD */
+ insert into acs_form_widgets (widget) values ('hidden');
+
+ insert into acs_form_allowable_widgets
+ (datatype, widget)
+ values
+ ('string','hidden');
+
+ insert into acs_form_allowable_widgets
+ (datatype, widget)
+ values
+ ('integer','hidden');
+
+ insert into acs_form_allowable_widgets
+ (datatype, widget)
+ values
+ ('naturalnum','hidden');
+
+ insert into acs_form_widget_params
+ (param_id, widget, param, required_p, html_p, tcl_allowed_p, default_value)
+ values
+ (260, 'hidden', 'value', 'f', 'f', 't', null);
+ /* End Hidden Widget */
+
+ /* TODO inform widget - Add to HEAD */
+ insert into acs_form_widgets (widget) values ('inform');
+
+ insert into acs_form_allowable_widgets
+ (datatype, widget)
+ values
+ ('string','inform');
+
+ insert into acs_form_allowable_widgets
+ (datatype, widget)
+ values
+ ('integer','inform');
+
+ insert into acs_form_allowable_widgets
+ (datatype, widget)
+ values
+ ('naturalnum','inform');
+
+ insert into acs_form_widget_params
+ (param_id, widget, param, required_p, html_p, tcl_allowed_p, default_value)
+ values
+ (261, 'inform', 'value', 'f', 'f', 't', null);
+
+ insert into acs_form_widget_params
+ (param_id, widget, param, required_p, html_p, tcl_allowed_p, default_value)
+ values
+ (262, 'inform', 'before_html', 'f', 'f', 't', null);
+
+ insert into acs_form_widget_params
+ (param_id, widget, param, required_p, html_p, tcl_allowed_p, default_value)
+ values
+ (263, 'inform', 'after_html', 'f', 'f', 't', null);
+
+ /* End inform Widget */
+
end;

Collapse
3: Re: Object Management (response to 1)
Posted by Dave Bauer on
Thanks.

New Question.

Is there a way to model one-many relationships with Acs Object Management?

Seems like a handy thing to be able to do.

I have no idea how that would work though...

Collapse
4: Re: Object Management (response to 3)
Posted by Torben Brosten on
Dave,

You mean besides using a one_object_id_to_many_id_map table?

Collapse
5: Re: Object Management (response to 3)
Posted by Ryan Gallimore on
Hi Dave,

Just create a naturalnum attribute on your object without a corresponding form widget and reference this back to its parent object.

Any foreign key constraints have to be created separately in a SQL script.