Forum OpenACS Q&A: Form Filter for Listbuilder

Collapse
Posted by Dave Bauer on
I have developed a way to generate a dynamic form from the filters definition in list builder.

The one issue I have in finally finishing this feature is the way to "know" if the page is using the form filter or not.

We need the form defined before the filter is applied to generate the where clause, so I have two options I can think of

1) call the procedure that generates the form on every call to template::list::create
2) add a switch to template::list::create to tell if the user will want to use the form filters.

I had hoped to just add a new filter template style, and I added a listfilters-form templating tag, because that seems like the correct place to choose which style of filters to display.

Any advice appreciated!

Collapse
Posted by Claudio Pasolini on
A new listfilters-form tag seems to me the way to go, provided that it can happily live with the normal listfilters tag.

Using forms and normal filters is challenging, because entering any data into an input field and submitting the form makes all the previously set filters cleared.

If template::list::create would take care of this problem, it would be very useful.

Collapse
Posted by Dave Bauer on
I added a boolean parameter -filter_form to template::list::create.

Now my only sticking point is creating a way to clear one filter attribute without clearing all of them. The current form code uses cookies to "remember" what filters you have applied and the values you have selected for each filter. This GREATLY simplifies the code.

Collapse
Posted by Claudio Pasolini on
In my custom solution to the problem I used ad_set_client_property to remember the filters, because if a user visits a great number of different lists his cookies could become cluttered.
Collapse
Posted by Malte Sussdorff on
This sounds great. Once you are done with it can you point to an application making use of this form filter? At the moment we always use a different form (ad_form) and pass the filters from the listbuilder (the normal ones) as export variables. Your approach seems to simplify the issue. Additionally, will it be possible to limit the filters used in the form, so you could say -filter_form [list of filters to use]. This would allow you to have the listbuilder in an include and pass the filters to be used on that particular page (similar to row_list).
Collapse
Posted by Dave Bauer on
Claudio,

Right, I use ad_set_client_property also, it doesn't actually store the data in the cookies itself.

Malte,

As soon as I am finished the first application using it will be dotlrn-ecommernce. I point to the code when its committed.